vendor: bump alibaba-cloud-sdk-go to v1.61.684

For commit [1]

 [1] 6313cc407e
This commit is contained in:
Yousong Zhou
2020-11-23 21:08:24 +08:00
parent 3bbaedaa7f
commit fe6714b287
509 changed files with 16940 additions and 4273 deletions

2
go.mod
View File

@@ -16,7 +16,7 @@ require (
github.com/Shopify/sarama v1.20.0 // indirect
github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20181031125837-1b0ec6f46eb1
github.com/aliyun/alibaba-cloud-sdk-go v1.61.684
github.com/aliyun/aliyun-oss-go-sdk v2.0.4+incompatible
github.com/anacrolix/dht v0.0.0-20181129074040-b09db78595aa // indirect
github.com/anacrolix/go-libutp v0.0.0-20180808010927-aebbeb60ea05 // indirect

4
go.sum
View File

@@ -99,6 +99,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZq
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20181031125837-1b0ec6f46eb1 h1:RbqM7Lb9R51eaIDUVNVmdF6nIf702njnnMQurROHDdQ=
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20181031125837-1b0ec6f46eb1/go.mod h1:T9M45xf79ahXVelWoOBmH0y4aC1t5kXO5BxwyakgIGA=
github.com/aliyun/alibaba-cloud-sdk-go v1.61.684 h1:MHqPW0la4Op96JGMkpB7Kxrz0Se5nowF6rLhHTZBUn4=
github.com/aliyun/alibaba-cloud-sdk-go v1.61.684/go.mod h1:pUKYbK5JQ+1Dfxk80P0qxGqe5dkxDoabbZS7zOcouyA=
github.com/aliyun/aliyun-oss-go-sdk v2.0.4+incompatible h1:EaK5256H3ELiyaq5O/Zwd6fnghD6DqmZDQmmzzJklUU=
github.com/aliyun/aliyun-oss-go-sdk v2.0.4+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/anacrolix/dht v0.0.0-20180412060941-24cbf25b72a4/go.mod h1:hQfX2BrtuQsLQMYQwsypFAab/GvHg8qxwVi4OJdR1WI=
@@ -347,6 +349,7 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I=
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
github.com/golang-plus/errors v1.0.0 h1:9Rh4itnph6OYO7wm9u3FUTLMFMKCoL07+bLiYKELxWw=
github.com/golang-plus/errors v1.0.0/go.mod h1:YTFZjOTBcUFieeZe4q+7Umfu/sceSr3XQyBIkTkzpd8=
github.com/golang-plus/testing v1.0.0 h1:azmFWFV44LHK/j/jAkNTbzB2G2b6HdmqF358r73m8kg=
@@ -462,6 +465,7 @@ github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/jsimonetti/rtnetlink v0.0.0-20190606172950-9527aa82566a/go.mod h1:Oz+70psSo5OFh8DBl0Zv2ACw7Esh6pPUphlvZG9x7uw=
github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=

View File

@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@@ -0,0 +1,249 @@
package sdk
import (
"encoding/json"
"strings"
"time"
)
var apiTimeouts = `{
"ecs": {
"ActivateRouterInterface": 10,
"AddTags": 61,
"AllocateDedicatedHosts": 10,
"AllocateEipAddress": 17,
"AllocatePublicIpAddress": 36,
"ApplyAutoSnapshotPolicy": 10,
"AssignIpv6Addresses": 10,
"AssignPrivateIpAddresses": 10,
"AssociateEipAddress": 17,
"AttachClassicLinkVpc": 14,
"AttachDisk": 36,
"AttachInstanceRamRole": 11,
"AttachKeyPair": 16,
"AttachNetworkInterface": 16,
"AuthorizeSecurityGroupEgress": 16,
"AuthorizeSecurityGroup": 16,
"CancelAutoSnapshotPolicy": 10,
"CancelCopyImage": 10,
"CancelPhysicalConnection": 10,
"CancelSimulatedSystemEvents": 10,
"CancelTask": 10,
"ConnectRouterInterface": 10,
"ConvertNatPublicIpToEip": 12,
"CopyImage": 10,
"CreateAutoSnapshotPolicy": 10,
"CreateCommand": 16,
"CreateDeploymentSet": 16,
"CreateDisk": 36,
"CreateHpcCluster": 10,
"CreateImage": 36,
"CreateInstance": 86,
"CreateKeyPair": 10,
"CreateLaunchTemplate": 10,
"CreateLaunchTemplateVersion": 10,
"CreateNatGateway": 36,
"CreateNetworkInterfacePermission": 13,
"CreateNetworkInterface": 16,
"CreatePhysicalConnection": 10,
"CreateRouteEntry": 17,
"CreateRouterInterface": 10,
"CreateSecurityGroup": 86,
"CreateSimulatedSystemEvents": 10,
"CreateSnapshot": 86,
"CreateVirtualBorderRouter": 10,
"CreateVpc": 16,
"CreateVSwitch": 17,
"DeactivateRouterInterface": 10,
"DeleteAutoSnapshotPolicy": 10,
"DeleteBandwidthPackage": 10,
"DeleteCommand": 16,
"DeleteDeploymentSet": 12,
"DeleteDisk": 16,
"DeleteHpcCluster": 10,
"DeleteImage": 36,
"DeleteInstance": 66,
"DeleteKeyPairs": 10,
"DeleteLaunchTemplate": 10,
"DeleteLaunchTemplateVersion": 10,
"DeleteNatGateway": 10,
"DeleteNetworkInterfacePermission": 10,
"DeleteNetworkInterface": 16,
"DeletePhysicalConnection": 10,
"DeleteRouteEntry": 16,
"DeleteRouterInterface": 10,
"DeleteSecurityGroup": 87,
"DeleteSnapshot": 17,
"DeleteVirtualBorderRouter": 10,
"DeleteVpc": 17,
"DeleteVSwitch": 17,
"DescribeAccessPoints": 10,
"DescribeAccountAttributes": 10,
"DescribeAutoSnapshotPolicyEx": 16,
"DescribeAvailableResource": 10,
"DescribeBandwidthLimitation": 16,
"DescribeBandwidthPackages": 10,
"DescribeClassicLinkInstances": 15,
"DescribeCloudAssistantStatus": 16,
"DescribeClusters": 10,
"DescribeCommands": 16,
"DescribeDedicatedHosts": 10,
"DescribeDedicatedHostTypes": 10,
"DescribeDeploymentSets": 26,
"DescribeDiskMonitorData": 16,
"DescribeDisksFullStatus": 14,
"DescribeDisks": 19,
"DescribeEipAddresses": 16,
"DescribeEipMonitorData": 16,
"DescribeEniMonitorData": 10,
"DescribeHaVips": 10,
"DescribeHpcClusters": 16,
"DescribeImageSharePermission": 10,
"DescribeImages": 38,
"DescribeImageSupportInstanceTypes": 16,
"DescribeInstanceAttribute": 36,
"DescribeInstanceAutoRenewAttribute": 17,
"DescribeInstanceHistoryEvents": 19,
"DescribeInstanceMonitorData": 19,
"DescribeInstancePhysicalAttribute": 10,
"DescribeInstanceRamRole": 11,
"DescribeInstancesFullStatus": 14,
"DescribeInstances": 10,
"DescribeInstanceStatus": 26,
"DescribeInstanceTopology": 12,
"DescribeInstanceTypeFamilies": 17,
"DescribeInstanceTypes": 17,
"DescribeInstanceVncPasswd": 10,
"DescribeInstanceVncUrl": 36,
"DescribeInvocationResults": 16,
"DescribeInvocations": 16,
"DescribeKeyPairs": 12,
"DescribeLaunchTemplates": 16,
"DescribeLaunchTemplateVersions": 16,
"DescribeLimitation": 36,
"DescribeNatGateways": 10,
"DescribeNetworkInterfacePermissions": 13,
"DescribeNetworkInterfaces": 16,
"DescribeNewProjectEipMonitorData": 16,
"DescribePhysicalConnections": 10,
"DescribePrice": 16,
"DescribeRecommendInstanceType": 10,
"DescribeRegions": 19,
"DescribeRenewalPrice": 16,
"DescribeResourceByTags": 10,
"DescribeResourcesModification": 17,
"DescribeRouterInterfaces": 10,
"DescribeRouteTables": 17,
"DescribeSecurityGroupAttribute": 133,
"DescribeSecurityGroupReferences": 16,
"DescribeSecurityGroups": 25,
"DescribeSnapshotLinks": 17,
"DescribeSnapshotMonitorData": 12,
"DescribeSnapshotPackage": 10,
"DescribeSnapshots": 26,
"DescribeSnapshotsUsage": 26,
"DescribeSpotPriceHistory": 22,
"DescribeTags": 17,
"DescribeTaskAttribute": 10,
"DescribeTasks": 11,
"DescribeUserBusinessBehavior": 13,
"DescribeUserData": 10,
"DescribeVirtualBorderRoutersForPhysicalConnection": 10,
"DescribeVirtualBorderRouters": 10,
"DescribeVpcs": 41,
"DescribeVRouters": 17,
"DescribeVSwitches": 17,
"DescribeZones": 103,
"DetachClassicLinkVpc": 14,
"DetachDisk": 17,
"DetachInstanceRamRole": 10,
"DetachKeyPair": 10,
"DetachNetworkInterface": 16,
"EipFillParams": 19,
"EipFillProduct": 13,
"EipNotifyPaid": 10,
"EnablePhysicalConnection": 10,
"ExportImage": 10,
"GetInstanceConsoleOutput": 14,
"GetInstanceScreenshot": 14,
"ImportImage": 29,
"ImportKeyPair": 10,
"InstallCloudAssistant": 10,
"InvokeCommand": 16,
"JoinResourceGroup": 10,
"JoinSecurityGroup": 66,
"LeaveSecurityGroup": 66,
"ModifyAutoSnapshotPolicyEx": 10,
"ModifyBandwidthPackageSpec": 11,
"ModifyCommand": 10,
"ModifyDeploymentSetAttribute": 10,
"ModifyDiskAttribute": 16,
"ModifyDiskChargeType": 13,
"ModifyEipAddressAttribute": 14,
"ModifyImageAttribute": 10,
"ModifyImageSharePermission": 16,
"ModifyInstanceAttribute": 22,
"ModifyInstanceAutoReleaseTime": 15,
"ModifyInstanceAutoRenewAttribute": 16,
"ModifyInstanceChargeType": 22,
"ModifyInstanceDeployment": 10,
"ModifyInstanceNetworkSpec": 36,
"ModifyInstanceSpec": 62,
"ModifyInstanceVncPasswd": 35,
"ModifyInstanceVpcAttribute": 15,
"ModifyLaunchTemplateDefaultVersion": 10,
"ModifyNetworkInterfaceAttribute": 10,
"ModifyPhysicalConnectionAttribute": 10,
"ModifyPrepayInstanceSpec": 13,
"ModifyRouterInterfaceAttribute": 10,
"ModifySecurityGroupAttribute": 10,
"ModifySecurityGroupEgressRule": 10,
"ModifySecurityGroupPolicy": 10,
"ModifySecurityGroupRule": 16,
"ModifySnapshotAttribute": 10,
"ModifyUserBusinessBehavior": 10,
"ModifyVirtualBorderRouterAttribute": 10,
"ModifyVpcAttribute": 10,
"ModifyVRouterAttribute": 10,
"ModifyVSwitchAttribute": 10,
"ReActivateInstances": 10,
"RebootInstance": 27,
"RedeployInstance": 14,
"ReInitDisk": 16,
"ReleaseDedicatedHost": 10,
"ReleaseEipAddress": 16,
"ReleasePublicIpAddress": 10,
"RemoveTags": 10,
"RenewInstance": 19,
"ReplaceSystemDisk": 36,
"ResetDisk": 36,
"ResizeDisk": 11,
"RevokeSecurityGroupEgress": 13,
"RevokeSecurityGroup": 16,
"RunInstances": 86,
"StartInstance": 46,
"StopInstance": 27,
"StopInvocation": 10,
"TerminatePhysicalConnection": 10,
"TerminateVirtualBorderRouter": 10,
"UnassignIpv6Addresses": 10,
"UnassignPrivateIpAddresses": 10,
"UnassociateEipAddress": 16
}
}
`
func getAPIMaxTimeout(product, actionName string) (time.Duration, bool) {
timeout := make(map[string]map[string]int)
err := json.Unmarshal([]byte(apiTimeouts), &timeout)
if err != nil {
return 0 * time.Millisecond, false
}
obj := timeout[strings.ToLower(product)]
if obj != nil && obj[actionName] != 0 {
return time.Duration(obj[actionName]) * time.Second, true
}
return 0 * time.Millisecond, false
}

View File

@@ -0,0 +1,12 @@
package credentials
type BearerTokenCredential struct {
BearerToken string
}
// NewBearerTokenCredential return a BearerTokenCredential object
func NewBearerTokenCredential(token string) *BearerTokenCredential {
return &BearerTokenCredential{
BearerToken: token,
}
}

View File

@@ -1,17 +1,5 @@
package credentials
// Deprecated: Use EcsRamRoleCredential in this package instead.
type StsRoleNameOnEcsCredential struct {
RoleName string
}
// Deprecated: Use NewEcsRamRoleCredential in this package instead.
func NewStsRoleNameOnEcsCredential(roleName string) *StsRoleNameOnEcsCredential {
return &StsRoleNameOnEcsCredential{
RoleName: roleName,
}
}
func (oldCred *StsRoleNameOnEcsCredential) ToEcsRamRoleCredential() *EcsRamRoleCredential {
return &EcsRamRoleCredential{
RoleName: oldCred.RoleName,
@@ -27,3 +15,15 @@ func NewEcsRamRoleCredential(roleName string) *EcsRamRoleCredential {
RoleName: roleName,
}
}
// Deprecated: Use EcsRamRoleCredential in this package instead.
type StsRoleNameOnEcsCredential struct {
RoleName string
}
// Deprecated: Use NewEcsRamRoleCredential in this package instead.
func NewStsRoleNameOnEcsCredential(roleName string) *StsRoleNameOnEcsCredential {
return &StsRoleNameOnEcsCredential{
RoleName: roleName,
}
}

View File

@@ -0,0 +1,30 @@
package provider
import (
"errors"
"os"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
)
type EnvProvider struct{}
var ProviderEnv = new(EnvProvider)
func NewEnvProvider() Provider {
return &EnvProvider{}
}
func (p *EnvProvider) Resolve() (auth.Credential, error) {
accessKeyID, ok1 := os.LookupEnv(ENVAccessKeyID)
accessKeySecret, ok2 := os.LookupEnv(ENVAccessKeySecret)
if !ok1 || !ok2 {
return nil, nil
}
if accessKeyID == "" || accessKeySecret == "" {
return nil, errors.New("Environmental variable (ALIBABACLOUD_ACCESS_KEY_ID or ALIBABACLOUD_ACCESS_KEY_SECRET) is empty")
}
return credentials.NewAccessKeyCredential(accessKeyID, accessKeySecret), nil
}

View File

@@ -0,0 +1,92 @@
package provider
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
"time"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
)
var securityCredURL = "http://100.100.100.200/latest/meta-data/ram/security-credentials/"
type InstanceCredentialsProvider struct{}
var ProviderInstance = new(InstanceCredentialsProvider)
var HookGet = func(fn func(string) (int, []byte, error)) func(string) (int, []byte, error) {
return fn
}
func NewInstanceCredentialsProvider() Provider {
return &InstanceCredentialsProvider{}
}
func (p *InstanceCredentialsProvider) Resolve() (auth.Credential, error) {
roleName, ok := os.LookupEnv(ENVEcsMetadata)
if !ok {
return nil, nil
}
if roleName == "" {
return nil, errors.New("Environmental variable 'ALIBABA_CLOUD_ECS_METADATA' are empty")
}
status, content, err := HookGet(get)(securityCredURL + roleName)
if err != nil {
return nil, err
}
if status != 200 {
if status == 404 {
return nil, fmt.Errorf("The role was not found in the instance")
}
return nil, fmt.Errorf("Received %d when getting security credentials for %s", status, roleName)
}
body := make(map[string]interface{})
if err := json.Unmarshal(content, &body); err != nil {
return nil, err
}
accessKeyID, err := extractString(body, "AccessKeyId")
if err != nil {
return nil, err
}
accessKeySecret, err := extractString(body, "AccessKeySecret")
if err != nil {
return nil, err
}
securityToken, err := extractString(body, "SecurityToken")
if err != nil {
return nil, err
}
return credentials.NewStsTokenCredential(accessKeyID, accessKeySecret, securityToken), nil
}
func get(url string) (status int, content []byte, err error) {
httpClient := http.DefaultClient
httpClient.Timeout = 1 * time.Second
resp, err := httpClient.Get(url)
if err != nil {
return
}
defer resp.Body.Close()
content, err = ioutil.ReadAll(resp.Body)
return resp.StatusCode, content, err
}
func extractString(m map[string]interface{}, key string) (string, error) {
raw, ok := m[key]
if !ok {
return "", fmt.Errorf("%s not in map", key)
}
str, ok := raw.(string)
if !ok {
return "", fmt.Errorf("%s is not a string in map", key)
}
return str, nil
}

View File

@@ -0,0 +1,159 @@
package provider
import (
"bufio"
"errors"
"os"
"runtime"
"strings"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
ini "gopkg.in/ini.v1"
)
type ProfileProvider struct {
Profile string
}
var ProviderProfile = NewProfileProvider()
// NewProfileProvider receive zero or more parameters,
// when length of name is 0, the value of field Profile will be "default",
// and when there are multiple inputs, the function will take the
// first one and discard the other values.
func NewProfileProvider(name ...string) Provider {
p := new(ProfileProvider)
if len(name) == 0 {
p.Profile = "default"
} else {
p.Profile = name[0]
}
return p
}
// Resolve implements the Provider interface
// when credential type is rsa_key_pair, the content of private_key file
// must be able to be parsed directly into the required string
// that NewRsaKeyPairCredential function needed
func (p *ProfileProvider) Resolve() (auth.Credential, error) {
path, ok := os.LookupEnv(ENVCredentialFile)
if !ok {
var err error
path, err = checkDefaultPath()
if err != nil {
return nil, err
}
if path == "" {
return nil, nil
}
} else if path == "" {
return nil, errors.New("Environment variable '" + ENVCredentialFile + "' cannot be empty")
}
ini, err := ini.Load(path)
if err != nil {
return nil, errors.New("ERROR: Can not open file" + err.Error())
}
section, err := ini.GetSection(p.Profile)
if err != nil {
return nil, errors.New("ERROR: Can not load section" + err.Error())
}
value, err := section.GetKey("type")
if err != nil {
return nil, errors.New("ERROR: Can not find credential type" + err.Error())
}
switch value.String() {
case "access_key":
value1, err1 := section.GetKey("access_key_id")
value2, err2 := section.GetKey("access_key_secret")
if err1 != nil || err2 != nil {
return nil, errors.New("ERROR: Failed to get value")
}
if value1.String() == "" || value2.String() == "" {
return nil, errors.New("ERROR: Value can't be empty")
}
return credentials.NewAccessKeyCredential(value1.String(), value2.String()), nil
case "ecs_ram_role":
value1, err1 := section.GetKey("role_name")
if err1 != nil {
return nil, errors.New("ERROR: Failed to get value")
}
if value1.String() == "" {
return nil, errors.New("ERROR: Value can't be empty")
}
return credentials.NewEcsRamRoleCredential(value1.String()), nil
case "ram_role_arn":
value1, err1 := section.GetKey("access_key_id")
value2, err2 := section.GetKey("access_key_secret")
value3, err3 := section.GetKey("role_arn")
value4, err4 := section.GetKey("role_session_name")
if err1 != nil || err2 != nil || err3 != nil || err4 != nil {
return nil, errors.New("ERROR: Failed to get value")
}
if value1.String() == "" || value2.String() == "" || value3.String() == "" || value4.String() == "" {
return nil, errors.New("ERROR: Value can't be empty")
}
return credentials.NewRamRoleArnCredential(value1.String(), value2.String(), value3.String(), value4.String(), 3600), nil
case "rsa_key_pair":
value1, err1 := section.GetKey("public_key_id")
value2, err2 := section.GetKey("private_key_file")
if err1 != nil || err2 != nil {
return nil, errors.New("ERROR: Failed to get value")
}
if value1.String() == "" || value2.String() == "" {
return nil, errors.New("ERROR: Value can't be empty")
}
file, err := os.Open(value2.String())
if err != nil {
return nil, errors.New("ERROR: Can not get private_key")
}
defer file.Close()
var privateKey string
scan := bufio.NewScanner(file)
var data string
for scan.Scan() {
if strings.HasPrefix(scan.Text(), "----") {
continue
}
data += scan.Text() + "\n"
}
return credentials.NewRsaKeyPairCredential(privateKey, value1.String(), 3600), nil
default:
return nil, errors.New("ERROR: Failed to get credential")
}
}
// GetHomePath return home directory according to the system.
// if the environmental virables does not exist, will return empty
func GetHomePath() string {
if runtime.GOOS == "windows" {
path, ok := os.LookupEnv("USERPROFILE")
if !ok {
return ""
}
return path
}
path, ok := os.LookupEnv("HOME")
if !ok {
return ""
}
return path
}
func checkDefaultPath() (path string, err error) {
path = GetHomePath()
if path == "" {
return "", errors.New("The default credential file path is invalid")
}
path = strings.Replace("~/.alibabacloud/credentials", "~", path, 1)
_, err = os.Stat(path)
if err != nil {
return "", nil
}
return path, nil
}

View File

@@ -0,0 +1,19 @@
package provider
import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
)
//Environmental virables that may be used by the provider
const (
ENVAccessKeyID = "ALIBABA_CLOUD_ACCESS_KEY_ID"
ENVAccessKeySecret = "ALIBABA_CLOUD_ACCESS_KEY_SECRET"
ENVCredentialFile = "ALIBABA_CLOUD_CREDENTIALS_FILE"
ENVEcsMetadata = "ALIBABA_CLOUD_ECS_METADATA"
PATHCredentialFile = "~/.alibabacloud/credentials"
)
// When you want to customize the provider, you only need to implement the method of the interface.
type Provider interface {
Resolve() (auth.Credential, error)
}

View File

@@ -0,0 +1,34 @@
package provider
import (
"errors"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
)
type ProviderChain struct {
Providers []Provider
}
var defaultproviders = []Provider{ProviderEnv, ProviderProfile, ProviderInstance}
var DefaultChain = NewProviderChain(defaultproviders)
func NewProviderChain(providers []Provider) Provider {
return &ProviderChain{
Providers: providers,
}
}
func (p *ProviderChain) Resolve() (auth.Credential, error) {
for _, provider := range p.Providers {
creds, err := provider.Resolve()
if err != nil {
return nil, err
} else if err == nil && creds == nil {
continue
}
return creds, err
}
return nil, errors.New("No credential found")
}

View File

@@ -15,6 +15,7 @@ type RamRoleArnCredential struct {
RoleArn string
RoleSessionName string
RoleSessionExpiration int
Policy string
}
// Deprecated: Use RamRoleArnCredential in this package instead.
@@ -47,3 +48,14 @@ func NewRamRoleArnCredential(accessKeyId, accessKeySecret, roleArn, roleSessionN
RoleSessionExpiration: roleSessionExpiration,
}
}
func NewRamRoleArnWithPolicyCredential(accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string, roleSessionExpiration int) *RamRoleArnCredential {
return &RamRoleArnCredential{
AccessKeyId: accessKeyId,
AccessKeySecret: accessKeySecret,
RoleArn: roleArn,
RoleSessionName: roleSessionName,
RoleSessionExpiration: roleSessionExpiration,
Policy: policy,
}
}

View File

@@ -16,22 +16,33 @@ package auth
import (
"bytes"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
"sort"
"strings"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
)
var debug utils.Debug
var hookGetDate = func(fn func() string) string {
return fn()
}
func init() {
debug = utils.Init("sdk")
}
func signRoaRequest(request requests.AcsRequest, signer Signer, regionId string) (err error) {
completeROASignParams(request, signer, regionId)
stringToSign := buildRoaStringToSign(request)
request.SetStringToSign(stringToSign)
signature := signer.Sign(stringToSign, "")
accessKeyId, err := signer.GetAccessKeyId()
if err != nil {
return nil
return err
}
signature := signer.Sign(stringToSign, "")
request.GetHeaders()["Authorization"] = "acs " + accessKeyId + ":" + signature
return
@@ -51,19 +62,24 @@ func completeROASignParams(request requests.AcsRequest, signer Signer, regionId
headerParams["x-acs-security-token"] = value
continue
}
if key == "BearerToken" {
headerParams["x-acs-bearer-token"] = value
continue
}
queryParams[key] = value
}
}
// complete header params
headerParams["Date"] = utils.GetTimeInFormatRFC2616()
headerParams["Date"] = hookGetDate(utils.GetTimeInFormatRFC2616)
headerParams["x-acs-signature-method"] = signer.GetName()
headerParams["x-acs-signature-version"] = signer.GetVersion()
if request.GetFormParams() != nil && len(request.GetFormParams()) > 0 {
formString := utils.GetUrlFormedMap(request.GetFormParams())
request.SetContent([]byte(formString))
headerParams["Content-Type"] = requests.Form
if headerParams["Content-Type"] == "" {
headerParams["Content-Type"] = requests.Form
}
}
contentMD5 := utils.GetMD5Base64(request.GetContent())
headerParams["Content-MD5"] = contentMD5
@@ -110,6 +126,7 @@ func buildRoaStringToSign(request requests.AcsRequest) (stringToSign string) {
// append query params
stringToSignBuilder.WriteString(request.BuildQueries())
stringToSign = stringToSignBuilder.String()
debug("stringToSign: %s", stringToSign)
return
}

View File

@@ -15,13 +15,17 @@
package auth
import (
"net/url"
"strings"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
"net/url"
"sort"
"strings"
)
var hookGetNonce = func(fn func() string) string {
return fn()
}
func signRpcRequest(request requests.AcsRequest, signer Signer, regionId string) (err error) {
err = completeRpcSignParams(request, signer, regionId)
if err != nil {
@@ -44,11 +48,11 @@ func completeRpcSignParams(request requests.AcsRequest, signer Signer, regionId
queryParams["Version"] = request.GetVersion()
queryParams["Action"] = request.GetActionName()
queryParams["Format"] = request.GetAcceptFormat()
queryParams["Timestamp"] = utils.GetTimeInFormatISO8601()
queryParams["Timestamp"] = hookGetDate(utils.GetTimeInFormatISO8601)
queryParams["SignatureMethod"] = signer.GetName()
queryParams["SignatureType"] = signer.GetType()
queryParams["SignatureVersion"] = signer.GetVersion()
queryParams["SignatureNonce"] = utils.GetUUIDV4()
queryParams["SignatureNonce"] = hookGetNonce(utils.GetUUID)
queryParams["AccessKeyId"], err = signer.GetAccessKeyId()
if err != nil {
@@ -80,12 +84,6 @@ func buildRpcStringToSign(request requests.AcsRequest) (stringToSign string) {
signParams[key] = value
}
// sort params by key
var paramKeySlice []string
for key := range signParams {
paramKeySlice = append(paramKeySlice, key)
}
sort.Strings(paramKeySlice)
stringToSign = utils.GetUrlFormedMap(signParams)
stringToSign = strings.Replace(stringToSign, "+", "%20", -1)
stringToSign = strings.Replace(stringToSign, "*", "%2A", -1)

View File

@@ -16,12 +16,13 @@ package auth
import (
"fmt"
"reflect"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
"reflect"
)
type Signer interface {
@@ -31,20 +32,22 @@ type Signer interface {
GetAccessKeyId() (string, error)
GetExtraParam() map[string]string
Sign(stringToSign, secretSuffix string) string
Shutdown()
}
func NewSignerWithCredential(credential Credential, commonApi func(request *requests.CommonRequest, signer interface{}) (response *responses.CommonResponse, err error)) (signer Signer, err error) {
switch instance := credential.(type) {
case *credentials.AccessKeyCredential:
{
signer, err = signers.NewAccessKeySigner(instance)
signer = signers.NewAccessKeySigner(instance)
}
case *credentials.StsTokenCredential:
{
signer, err = signers.NewStsTokenSigner(instance)
signer = signers.NewStsTokenSigner(instance)
}
case *credentials.BearerTokenCredential:
{
signer = signers.NewBearerTokenSigner(instance)
}
case *credentials.RamRoleArnCredential:
{
signer, err = signers.NewRamRoleArnSigner(instance, commonApi)
@@ -55,11 +58,11 @@ func NewSignerWithCredential(credential Credential, commonApi func(request *requ
}
case *credentials.EcsRamRoleCredential:
{
signer, err = signers.NewEcsRamRoleSigner(instance, commonApi)
signer = signers.NewEcsRamRoleSigner(instance, commonApi)
}
case *credentials.BaseCredential: // deprecated user interface
{
signer, err = signers.NewAccessKeySigner(instance.ToAccessKeyCredential())
signer = signers.NewAccessKeySigner(instance.ToAccessKeyCredential())
}
case *credentials.StsRoleArnCredential: // deprecated user interface
{
@@ -67,7 +70,7 @@ func NewSignerWithCredential(credential Credential, commonApi func(request *requ
}
case *credentials.StsRoleNameOnEcsCredential: // deprecated user interface
{
signer, err = signers.NewEcsRamRoleSigner(instance.ToEcsRamRoleCredential(), commonApi)
signer = signers.NewEcsRamRoleSigner(instance.ToEcsRamRoleCredential(), commonApi)
}
default:
message := fmt.Sprintf(errors.UnsupportedCredentialErrorMessage, reflect.TypeOf(credential))
@@ -80,7 +83,7 @@ func Sign(request requests.AcsRequest, signer Signer, regionId string) (err erro
switch request.GetStyle() {
case requests.ROA:
{
signRoaRequest(request, signer, regionId)
err = signRoaRequest(request, signer, regionId)
}
case requests.RPC:
{

View File

@@ -22,11 +22,7 @@ import (
"crypto/sha1"
"crypto/x509"
"encoding/base64"
"fmt"
/*"encoding/pem"
"io/ioutil"
"os/user"
"crypto/sha256"*/)
)
func ShaHmac1(source, secret string) string {
key := []byte(secret)
@@ -38,13 +34,14 @@ func ShaHmac1(source, secret string) string {
}
func Sha256WithRsa(source, secret string) string {
// block, _ := pem.Decode([]byte(secret))
decodeString, err := base64.StdEncoding.DecodeString(secret)
if err != nil {
fmt.Println("DecodeString err", err)
panic(err)
}
private, err := x509.ParsePKCS8PrivateKey(decodeString)
if err != nil {
fmt.Println("ParsePKCS8PrivateKey err", err)
panic(err)
}
h := crypto.Hash.New(crypto.SHA256)
@@ -53,11 +50,8 @@ func Sha256WithRsa(source, secret string) string {
signature, err := rsa.SignPKCS1v15(rand.Reader, private.(*rsa.PrivateKey),
crypto.SHA256, hashed)
if err != nil {
fmt.Println("Error from signing:", err)
return ""
panic(err)
}
signedString := base64.StdEncoding.EncodeToString(signature)
//fmt.Printf("Encoded: %v\n", signedString)
return signedString
return base64.StdEncoding.EncodeToString(signature)
}

View File

@@ -15,12 +15,13 @@
package signers
import (
"time"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
"time"
)
const defaultInAdvanceScale = 0.8
const defaultInAdvanceScale = 0.95
type credentialUpdater struct {
credentialExpiration int

View File

@@ -26,10 +26,10 @@ func (signer *AccessKeySigner) GetExtraParam() map[string]string {
return nil
}
func NewAccessKeySigner(credential *credentials.AccessKeyCredential) (*AccessKeySigner, error) {
func NewAccessKeySigner(credential *credentials.AccessKeyCredential) *AccessKeySigner {
return &AccessKeySigner{
credential: credential,
}, nil
}
}
func (*AccessKeySigner) GetName() string {
@@ -52,7 +52,3 @@ func (signer *AccessKeySigner) Sign(stringToSign, secretSuffix string) string {
secret := signer.credential.AccessKeySecret + secretSuffix
return ShaHmac1(stringToSign, secret)
}
func (signer *AccessKeySigner) Shutdown() {
}

View File

@@ -0,0 +1,35 @@
package signers
import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
)
type BearerTokenSigner struct {
credential *credentials.BearerTokenCredential
}
func NewBearerTokenSigner(credential *credentials.BearerTokenCredential) *BearerTokenSigner {
return &BearerTokenSigner{
credential: credential,
}
}
func (signer *BearerTokenSigner) GetExtraParam() map[string]string {
return map[string]string{"BearerToken": signer.credential.BearerToken}
}
func (*BearerTokenSigner) GetName() string {
return ""
}
func (*BearerTokenSigner) GetType() string {
return "BEARERTOKEN"
}
func (*BearerTokenSigner) GetVersion() string {
return "1.0"
}
func (signer *BearerTokenSigner) GetAccessKeyId() (accessKeyId string, err error) {
return "", nil
}
func (signer *BearerTokenSigner) Sign(stringToSign, secretSuffix string) string {
return ""
}

View File

@@ -17,15 +17,18 @@ package signers
import (
"encoding/json"
"fmt"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
"github.com/jmespath/go-jmespath"
"net/http"
"strings"
"time"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
jmespath "github.com/jmespath/go-jmespath"
)
var securityCredURL = "http://100.100.100.200/latest/meta-data/ram/security-credentials/"
type EcsRamRoleSigner struct {
*credentialUpdater
sessionCredential *SessionCredential
@@ -33,7 +36,7 @@ type EcsRamRoleSigner struct {
commonApi func(request *requests.CommonRequest, signer interface{}) (response *responses.CommonResponse, err error)
}
func NewEcsRamRoleSigner(credential *credentials.EcsRamRoleCredential, commonApi func(*requests.CommonRequest, interface{}) (response *responses.CommonResponse, err error)) (signer *EcsRamRoleSigner, err error) {
func NewEcsRamRoleSigner(credential *credentials.EcsRamRoleCredential, commonApi func(*requests.CommonRequest, interface{}) (response *responses.CommonResponse, err error)) (signer *EcsRamRoleSigner) {
signer = &EcsRamRoleSigner{
credential: credential,
commonApi: commonApi,
@@ -46,7 +49,7 @@ func NewEcsRamRoleSigner(credential *credentials.EcsRamRoleCredential, commonApi
refreshApi: signer.refreshApi,
}
return
return signer
}
func (*EcsRamRoleSigner) GetName() string {
@@ -64,9 +67,12 @@ func (*EcsRamRoleSigner) GetVersion() string {
func (signer *EcsRamRoleSigner) GetAccessKeyId() (accessKeyId string, err error) {
if signer.sessionCredential == nil || signer.needUpdateCredential() {
err = signer.updateCredential()
if err != nil {
return
}
}
if err != nil && (signer.sessionCredential == nil || len(signer.sessionCredential.AccessKeyId) <= 0) {
return "", err
if signer.sessionCredential == nil || len(signer.sessionCredential.AccessKeyId) <= 0 {
return "", nil
}
return signer.sessionCredential.AccessKeyId, nil
}
@@ -82,76 +88,66 @@ func (signer *EcsRamRoleSigner) GetExtraParam() map[string]string {
}
func (signer *EcsRamRoleSigner) Sign(stringToSign, secretSuffix string) string {
secret := signer.sessionCredential.AccessKeyId + secretSuffix
secret := signer.sessionCredential.AccessKeySecret + secretSuffix
return ShaHmac1(stringToSign, secret)
}
func (signer *EcsRamRoleSigner) buildCommonRequest() (request *requests.CommonRequest, err error) {
request = requests.NewCommonRequest()
return
}
func (signer *EcsRamRoleSigner) refreshApi(request *requests.CommonRequest) (response *responses.CommonResponse, err error) {
requestUrl := "http://100.100.100.200/latest/meta-data/ram/security-credentials/" + signer.credential.RoleName
requestUrl := securityCredURL + signer.credential.RoleName
httpRequest, err := http.NewRequest(requests.GET, requestUrl, strings.NewReader(""))
if err != nil {
fmt.Println("refresh Ecs sts token err", err)
err = fmt.Errorf("refresh Ecs sts token err: %s", err.Error())
return
}
httpClient := &http.Client{}
httpResponse, err := httpClient.Do(httpRequest)
if err != nil {
fmt.Println("refresh Ecs sts token err", err)
err = fmt.Errorf("refresh Ecs sts token err: %s", err.Error())
return
}
response = responses.NewCommonResponse()
err = responses.Unmarshal(response, httpResponse, "")
return
}
func (signer *EcsRamRoleSigner) refreshCredential(response *responses.CommonResponse) (err error) {
if response.GetHttpStatus() != http.StatusOK {
fmt.Println("refresh Ecs sts token err, httpStatus: " + string(response.GetHttpStatus()) + ", message = " + response.GetHttpContentString())
return
return fmt.Errorf("refresh Ecs sts token err, httpStatus: %d, message = %s", response.GetHttpStatus(), response.GetHttpContentString())
}
var data interface{}
err = json.Unmarshal(response.GetHttpContentBytes(), &data)
if err != nil {
fmt.Println("refresh Ecs sts token err, json.Unmarshal fail", err)
return
return fmt.Errorf("refresh Ecs sts token err, json.Unmarshal fail: %s", err.Error())
}
code, err := jmespath.Search("Code", data)
if err != nil {
fmt.Println("refresh Ecs sts token err, fail to get Code", err)
return
return fmt.Errorf("refresh Ecs sts token err, fail to get Code: %s", err.Error())
}
if code.(string) != "Success" {
fmt.Println("refresh Ecs sts token err, Code is not Success", err)
return
return fmt.Errorf("refresh Ecs sts token err, Code is not Success")
}
accessKeyId, err := jmespath.Search("AccessKeyId", data)
if err != nil {
fmt.Println("refresh Ecs sts token err, fail to get AccessKeyId", err)
return
return fmt.Errorf("refresh Ecs sts token err, fail to get AccessKeyId: %s", err.Error())
}
accessKeySecret, err := jmespath.Search("AccessKeySecret", data)
if err != nil {
fmt.Println("refresh Ecs sts token err, fail to get AccessKeySecret", err)
return
return fmt.Errorf("refresh Ecs sts token err, fail to get AccessKeySecret: %s", err.Error())
}
securityToken, err := jmespath.Search("SecurityToken", data)
if err != nil {
fmt.Println("refresh Ecs sts token err, fail to get SecurityToken", err)
return
return fmt.Errorf("refresh Ecs sts token err, fail to get SecurityToken: %s", err.Error())
}
expiration, err := jmespath.Search("Expiration", data)
if err != nil {
fmt.Println("refresh Ecs sts token err, fail to get Expiration", err)
return
return fmt.Errorf("refresh Ecs sts token err, fail to get Expiration: %s", err.Error())
}
if accessKeyId == nil || accessKeySecret == nil || securityToken == nil {
if accessKeyId == nil || accessKeySecret == nil || securityToken == nil || expiration == nil {
return
}
@@ -169,7 +165,3 @@ func (signer *EcsRamRoleSigner) refreshCredential(response *responses.CommonResp
func (signer *EcsRamRoleSigner) GetSessionCredential() *SessionCredential {
return signer.sessionCredential
}
func (signer *EcsRamRoleSigner) Shutdown() {
}

View File

@@ -17,13 +17,14 @@ package signers
import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
"github.com/jmespath/go-jmespath"
"net/http"
"strconv"
jmespath "github.com/jmespath/go-jmespath"
)
type SignerKeyPair struct {
@@ -70,28 +71,33 @@ func (*SignerKeyPair) GetVersion() string {
return "1.0"
}
func (signer *SignerKeyPair) GetAccessKeyId() (accessKeyId string, err error) {
func (signer *SignerKeyPair) ensureCredential() error {
if signer.sessionCredential == nil || signer.needUpdateCredential() {
err = signer.updateCredential()
return signer.updateCredential()
}
if err != nil && (signer.sessionCredential == nil || len(signer.sessionCredential.AccessKeyId) <= 0) {
return "", err
return nil
}
func (signer *SignerKeyPair) GetAccessKeyId() (accessKeyId string, err error) {
err = signer.ensureCredential()
if err != nil {
return
}
return signer.sessionCredential.AccessKeyId, err
if signer.sessionCredential == nil || len(signer.sessionCredential.AccessKeyId) <= 0 {
accessKeyId = ""
return
}
accessKeyId = signer.sessionCredential.AccessKeyId
return
}
func (signer *SignerKeyPair) GetExtraParam() map[string]string {
if signer.sessionCredential == nil || signer.needUpdateCredential() {
signer.updateCredential()
}
if signer.sessionCredential == nil || len(signer.sessionCredential.AccessKeyId) <= 0 {
return make(map[string]string)
}
return make(map[string]string)
}
func (signer *SignerKeyPair) Sign(stringToSign, secretSuffix string) string {
secret := signer.sessionCredential.AccessKeyId + secretSuffix
secret := signer.sessionCredential.AccessKeySecret + secretSuffix
return ShaHmac1(stringToSign, secret)
}
@@ -101,14 +107,15 @@ func (signer *SignerKeyPair) buildCommonRequest() (request *requests.CommonReque
request.Version = "2015-04-01"
request.ApiName = "GenerateSessionAccessKey"
request.Scheme = requests.HTTPS
request.SetDomain("sts.ap-northeast-1.aliyuncs.com")
request.QueryParams["PublicKeyId"] = signer.credential.PublicKeyId
request.QueryParams["DurationSeconds"] = strconv.Itoa(signer.credentialExpiration)
return
}
func (signerKeyPair *SignerKeyPair) refreshApi(request *requests.CommonRequest) (response *responses.CommonResponse, err error) {
signerV2, err := NewSignerV2(signerKeyPair.credential)
return signerKeyPair.commonApi(request, signerV2)
func (signer *SignerKeyPair) refreshApi(request *requests.CommonRequest) (response *responses.CommonResponse, err error) {
signerV2 := NewSignerV2(signer.credential)
return signer.commonApi(request, signerV2)
}
func (signer *SignerKeyPair) refreshCredential(response *responses.CommonResponse) (err error) {
@@ -120,18 +127,15 @@ func (signer *SignerKeyPair) refreshCredential(response *responses.CommonRespons
var data interface{}
err = json.Unmarshal(response.GetHttpContentBytes(), &data)
if err != nil {
fmt.Println("refresh KeyPair err, json.Unmarshal fail", err)
return
return fmt.Errorf("refresh KeyPair err, json.Unmarshal fail: %s", err.Error())
}
accessKeyId, err := jmespath.Search("SessionAccessKey.SessionAccessKeyId", data)
if err != nil {
fmt.Println("refresh KeyPair err, fail to get SessionAccessKeyId", err)
return
return fmt.Errorf("refresh KeyPair err, fail to get SessionAccessKeyId: %s", err.Error())
}
accessKeySecret, err := jmespath.Search("SessionAccessKey.SessionAccessKeySecret", data)
if err != nil {
fmt.Println("refresh KeyPair err, fail to get SessionAccessKeySecret", err)
return
return fmt.Errorf("refresh KeyPair err, fail to get SessionAccessKeySecret: %s", err.Error())
}
if accessKeyId == nil || accessKeySecret == nil {
return
@@ -142,7 +146,3 @@ func (signer *SignerKeyPair) refreshCredential(response *responses.CommonRespons
}
return
}
func (signer *SignerKeyPair) Shutdown() {
}

View File

@@ -17,14 +17,15 @@ package signers
import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"time"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
"github.com/jmespath/go-jmespath"
"net/http"
"strconv"
"time"
jmespath "github.com/jmespath/go-jmespath"
)
const (
@@ -84,10 +85,15 @@ func (*RamRoleArnSigner) GetVersion() string {
func (signer *RamRoleArnSigner) GetAccessKeyId() (accessKeyId string, err error) {
if signer.sessionCredential == nil || signer.needUpdateCredential() {
err = signer.updateCredential()
if err != nil {
return
}
}
if err != nil && (signer.sessionCredential == nil || len(signer.sessionCredential.AccessKeyId) <= 0) {
if signer.sessionCredential == nil || len(signer.sessionCredential.AccessKeyId) <= 0 {
return "", err
}
return signer.sessionCredential.AccessKeyId, nil
}
@@ -113,6 +119,9 @@ func (signer *RamRoleArnSigner) buildCommonRequest() (request *requests.CommonRe
request.ApiName = "AssumeRole"
request.Scheme = requests.HTTPS
request.QueryParams["RoleArn"] = signer.credential.RoleArn
if signer.credential.Policy != "" {
request.QueryParams["Policy"] = signer.credential.Policy
}
request.QueryParams["RoleSessionName"] = signer.credential.RoleSessionName
request.QueryParams["DurationSeconds"] = strconv.Itoa(signer.credentialExpiration)
return
@@ -123,7 +132,7 @@ func (signer *RamRoleArnSigner) refreshApi(request *requests.CommonRequest) (res
AccessKeyId: signer.credential.AccessKeyId,
AccessKeySecret: signer.credential.AccessKeySecret,
}
signerV1, err := NewAccessKeySigner(credential)
signerV1 := NewAccessKeySigner(credential)
return signer.commonApi(request, signerV1)
}
@@ -136,23 +145,19 @@ func (signer *RamRoleArnSigner) refreshCredential(response *responses.CommonResp
var data interface{}
err = json.Unmarshal(response.GetHttpContentBytes(), &data)
if err != nil {
fmt.Println("refresh RoleArn sts token err, json.Unmarshal fail", err)
return
return fmt.Errorf("refresh RoleArn sts token err, json.Unmarshal fail: %s", err.Error())
}
accessKeyId, err := jmespath.Search("Credentials.AccessKeyId", data)
if err != nil {
fmt.Println("refresh RoleArn sts token err, fail to get AccessKeyId", err)
return
return fmt.Errorf("refresh RoleArn sts token err, fail to get AccessKeyId: %s", err.Error())
}
accessKeySecret, err := jmespath.Search("Credentials.AccessKeySecret", data)
if err != nil {
fmt.Println("refresh RoleArn sts token err, fail to get AccessKeySecret", err)
return
return fmt.Errorf("refresh RoleArn sts token err, fail to get AccessKeySecret: %s", err.Error())
}
securityToken, err := jmespath.Search("Credentials.SecurityToken", data)
if err != nil {
fmt.Println("refresh RoleArn sts token err, fail to get SecurityToken", err)
return
return fmt.Errorf("refresh RoleArn sts token err, fail to get SecurityToken: %s", err.Error())
}
if accessKeyId == nil || accessKeySecret == nil || securityToken == nil {
return
@@ -168,7 +173,3 @@ func (signer *RamRoleArnSigner) refreshCredential(response *responses.CommonResp
func (signer *RamRoleArnSigner) GetSessionCredential() *SessionCredential {
return signer.sessionCredential
}
func (signer *RamRoleArnSigner) Shutdown() {
}

View File

@@ -22,10 +22,10 @@ type StsTokenSigner struct {
credential *credentials.StsTokenCredential
}
func NewStsTokenSigner(credential *credentials.StsTokenCredential) (*StsTokenSigner, error) {
func NewStsTokenSigner(credential *credentials.StsTokenCredential) *StsTokenSigner {
return &StsTokenSigner{
credential: credential,
}, nil
}
}
func (*StsTokenSigner) GetName() string {
@@ -52,7 +52,3 @@ func (signer *StsTokenSigner) Sign(stringToSign, secretSuffix string) string {
secret := signer.credential.AccessKeySecret + secretSuffix
return ShaHmac1(stringToSign, secret)
}
func (signer *StsTokenSigner) Shutdown() {
}

View File

@@ -26,10 +26,10 @@ func (signer *SignerV2) GetExtraParam() map[string]string {
return nil
}
func NewSignerV2(credential *credentials.RsaKeyPairCredential) (*SignerV2, error) {
func NewSignerV2(credential *credentials.RsaKeyPairCredential) *SignerV2 {
return &SignerV2{
credential: credential,
}, nil
}
}
func (*SignerV2) GetName() string {
@@ -52,7 +52,3 @@ func (signer *SignerV2) Sign(stringToSign, secretSuffix string) string {
secret := signer.credential.PrivateKey
return Sha256WithRsa(stringToSign, secret)
}
func (signer *SignerV2) Shutdown() {
}

View File

@@ -15,28 +15,67 @@
package sdk
import (
"context"
"crypto/tls"
"fmt"
"net"
"net/http"
"net/url"
"os"
"regexp"
"runtime"
"strconv"
"strings"
"sync"
"time"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
"net"
"net/http"
"strconv"
"sync"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
)
// this value will be replaced while build: -ldflags="-X sdk.version=x.x.x"
var Version = "0.0.1"
var debug utils.Debug
func init() {
debug = utils.Init("sdk")
}
// Version this value will be replaced while build: -ldflags="-X sdk.version=x.x.x"
var Version = "0.0.1"
var defaultConnectTimeout = 5 * time.Second
var defaultReadTimeout = 10 * time.Second
var DefaultUserAgent = fmt.Sprintf("AlibabaCloud (%s; %s) Golang/%s Core/%s", runtime.GOOS, runtime.GOARCH, strings.Trim(runtime.Version(), "go"), Version)
var hookDo = func(fn func(req *http.Request) (*http.Response, error)) func(req *http.Request) (*http.Response, error) {
return fn
}
// Client the type Client
type Client struct {
isInsecure bool
regionId string
config *Config
httpProxy string
httpsProxy string
noProxy string
logger *Logger
userAgent map[string]string
signer auth.Signer
httpClient *http.Client
asyncTaskQueue chan func()
readTimeout time.Duration
connectTimeout time.Duration
EndpointMap map[string]string
EndpointType string
Network string
Domain string
isOpenAsync bool
debug bool
isRunning bool
@@ -48,17 +87,81 @@ func (client *Client) Init() (err error) {
panic("not support yet")
}
func (client *Client) SetEndpointRules(endpointMap map[string]string, endpointType string, netWork string) {
client.EndpointMap = endpointMap
client.Network = netWork
client.EndpointType = endpointType
}
func (client *Client) SetHTTPSInsecure(isInsecure bool) {
client.isInsecure = isInsecure
}
func (client *Client) GetHTTPSInsecure() bool {
return client.isInsecure
}
func (client *Client) SetHttpsProxy(httpsProxy string) {
client.httpsProxy = httpsProxy
}
func (client *Client) GetHttpsProxy() string {
return client.httpsProxy
}
func (client *Client) SetHttpProxy(httpProxy string) {
client.httpProxy = httpProxy
}
func (client *Client) GetHttpProxy() string {
return client.httpProxy
}
func (client *Client) SetNoProxy(noProxy string) {
client.noProxy = noProxy
}
func (client *Client) GetNoProxy() string {
return client.noProxy
}
func (client *Client) SetTransport(transport http.RoundTripper) {
if client.httpClient == nil {
client.httpClient = &http.Client{}
}
client.httpClient.Transport = transport
}
// InitWithProviderChain will get credential from the providerChain,
// the RsaKeyPairCredential Only applicable to regionID `ap-northeast-1`,
// if your providerChain may return a credential type with RsaKeyPairCredential,
// please ensure your regionID is `ap-northeast-1`.
func (client *Client) InitWithProviderChain(regionId string, provider provider.Provider) (err error) {
config := client.InitClientConfig()
credential, err := provider.Resolve()
if err != nil {
return
}
return client.InitWithOptions(regionId, config, credential)
}
func (client *Client) InitWithOptions(regionId string, config *Config, credential auth.Credential) (err error) {
if regionId != "" {
match, _ := regexp.MatchString("^[a-zA-Z0-9_-]+$", regionId)
if !match {
return fmt.Errorf("regionId contains invalid characters")
}
}
client.isRunning = true
client.asyncChanLock = new(sync.RWMutex)
client.regionId = regionId
client.config = config
if err != nil {
return
}
client.httpClient = &http.Client{}
if config.HttpTransport != nil {
if config.Transport != nil {
client.httpClient.Transport = config.Transport
} else if config.HttpTransport != nil {
client.httpClient.Transport = config.HttpTransport
}
@@ -75,11 +178,79 @@ func (client *Client) InitWithOptions(regionId string, config *Config, credentia
return
}
func (client *Client) SetReadTimeout(readTimeout time.Duration) {
client.readTimeout = readTimeout
}
func (client *Client) SetConnectTimeout(connectTimeout time.Duration) {
client.connectTimeout = connectTimeout
}
func (client *Client) GetReadTimeout() time.Duration {
return client.readTimeout
}
func (client *Client) GetConnectTimeout() time.Duration {
return client.connectTimeout
}
func (client *Client) getHttpProxy(scheme string) (proxy *url.URL, err error) {
if scheme == "https" {
if client.GetHttpsProxy() != "" {
proxy, err = url.Parse(client.httpsProxy)
} else if rawurl := os.Getenv("HTTPS_PROXY"); rawurl != "" {
proxy, err = url.Parse(rawurl)
} else if rawurl := os.Getenv("https_proxy"); rawurl != "" {
proxy, err = url.Parse(rawurl)
}
} else {
if client.GetHttpProxy() != "" {
proxy, err = url.Parse(client.httpProxy)
} else if rawurl := os.Getenv("HTTP_PROXY"); rawurl != "" {
proxy, err = url.Parse(rawurl)
} else if rawurl := os.Getenv("http_proxy"); rawurl != "" {
proxy, err = url.Parse(rawurl)
}
}
return proxy, err
}
func (client *Client) getNoProxy(scheme string) []string {
var urls []string
if client.GetNoProxy() != "" {
urls = strings.Split(client.noProxy, ",")
} else if rawurl := os.Getenv("NO_PROXY"); rawurl != "" {
urls = strings.Split(rawurl, ",")
} else if rawurl := os.Getenv("no_proxy"); rawurl != "" {
urls = strings.Split(rawurl, ",")
}
return urls
}
// EnableAsync enable the async task queue
func (client *Client) EnableAsync(routinePoolSize, maxTaskQueueSize int) {
client.asyncTaskQueue = make(chan func(), maxTaskQueueSize)
if client.isOpenAsync {
fmt.Println("warning: Please not call EnableAsync repeatedly")
return
}
if client.asyncChanLock == nil {
client.asyncChanLock = new(sync.RWMutex)
}
client.asyncChanLock.Lock()
defer client.asyncChanLock.Unlock()
client.isRunning = true
client.isOpenAsync = true
if client.asyncTaskQueue == nil {
client.asyncTaskQueue = make(chan func(), maxTaskQueueSize)
}
for i := 0; i < routinePoolSize; i++ {
go func() {
for client.isRunning {
client.asyncChanLock.RLock()
ok := client.isRunning
client.asyncChanLock.RUnlock()
for ok {
select {
case task, notClosed := <-client.asyncTaskQueue:
if notClosed {
@@ -121,6 +292,18 @@ func (client *Client) InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret,
return client.InitWithOptions(regionId, config, credential)
}
func (client *Client) InitWithRamRoleArnAndPolicy(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string) (err error) {
config := client.InitClientConfig()
credential := &credentials.RamRoleArnCredential{
AccessKeyId: accessKeyId,
AccessKeySecret: accessKeySecret,
RoleArn: roleArn,
RoleSessionName: roleSessionName,
Policy: policy,
}
return client.InitWithOptions(regionId, config, credential)
}
func (client *Client) InitWithRsaKeyPair(regionId, publicKeyId, privateKey string, sessionExpiration int) (err error) {
config := client.InitClientConfig()
credential := &credentials.RsaKeyPairCredential{
@@ -139,6 +322,14 @@ func (client *Client) InitWithEcsRamRole(regionId, roleName string) (err error)
return client.InitWithOptions(regionId, config, credential)
}
func (client *Client) InitWithBearerToken(regionId, bearerToken string) (err error) {
config := client.InitClientConfig()
credential := &credentials.BearerTokenCredential{
BearerToken: bearerToken,
}
return client.InitWithOptions(regionId, config, credential)
}
func (client *Client) InitClientConfig() (config *Config) {
if client.config != nil {
return client.config
@@ -151,52 +342,26 @@ func (client *Client) DoAction(request requests.AcsRequest, response responses.A
return client.DoActionWithSigner(request, response, nil)
}
func (client *Client) BuildRequestWithSigner(request requests.AcsRequest, signer auth.Signer) (err error) {
// add clientVersion
request.GetHeaders()["x-sdk-core-version"] = Version
regionId := client.regionId
if len(request.GetRegionId()) > 0 {
regionId = request.GetRegionId()
}
// resolve endpoint
resolveParam := &endpoints.ResolveParam{
Domain: request.GetDomain(),
Product: request.GetProduct(),
RegionId: regionId,
LocationProduct: request.GetLocationServiceCode(),
LocationEndpointType: request.GetLocationEndpointType(),
CommonApi: client.ProcessCommonRequest,
}
endpoint, err := endpoints.Resolve(resolveParam)
if err != nil {
return
}
request.SetDomain(endpoint)
// init request params
err = requests.InitParams(request)
if err != nil {
return
}
// signature
var finalSigner auth.Signer
if signer != nil {
finalSigner = signer
func (client *Client) GetEndpointRules(regionId string, product string) (endpointRaw string, err error) {
if client.EndpointType == "regional" {
if regionId == "" {
err = fmt.Errorf("RegionId is empty, please set a valid RegionId.")
return "", err
}
endpointRaw = strings.Replace("<product><network>.<region_id>.aliyuncs.com", "<region_id>", regionId, 1)
} else {
finalSigner = client.signer
endpointRaw = "<product><network>.aliyuncs.com"
}
httpRequest, err := buildHttpRequest(request, finalSigner, regionId)
if client.config.UserAgent != "" {
httpRequest.Header.Set("User-Agent", client.config.UserAgent)
endpointRaw = strings.Replace(endpointRaw, "<product>", strings.ToLower(product), 1)
if client.Network == "" || client.Network == "public" {
endpointRaw = strings.Replace(endpointRaw, "<network>", "", 1)
} else {
endpointRaw = strings.Replace(endpointRaw, "<network>", "-"+client.Network, 1)
}
return err
return endpointRaw, nil
}
func (client *Client) DoActionWithSigner(request requests.AcsRequest, response responses.AcsResponse, signer auth.Signer) (err error) {
func (client *Client) buildRequestWithSigner(request requests.AcsRequest, signer auth.Signer) (httpRequest *http.Request, err error) {
// add clientVersion
request.GetHeaders()["x-sdk-core-version"] = Version
@@ -206,20 +371,46 @@ func (client *Client) DoActionWithSigner(request requests.AcsRequest, response r
}
// resolve endpoint
resolveParam := &endpoints.ResolveParam{
Domain: request.GetDomain(),
Product: request.GetProduct(),
RegionId: regionId,
LocationProduct: request.GetLocationServiceCode(),
LocationEndpointType: request.GetLocationEndpointType(),
CommonApi: client.ProcessCommonRequest,
}
endpoint, err := endpoints.Resolve(resolveParam)
if err != nil {
return
}
request.SetDomain(endpoint)
endpoint := request.GetDomain()
if endpoint == "" && client.Domain != "" {
endpoint = client.Domain
}
if endpoint == "" {
endpoint = endpoints.GetEndpointFromMap(regionId, request.GetProduct())
}
if endpoint == "" && client.EndpointType != "" &&
(request.GetProduct() != "Sts" || len(request.GetQueryParams()) == 0) {
if client.EndpointMap != nil && client.Network == "" || client.Network == "public" {
endpoint = client.EndpointMap[regionId]
}
if endpoint == "" {
endpoint, err = client.GetEndpointRules(regionId, request.GetProduct())
if err != nil {
return
}
}
}
if endpoint == "" {
resolveParam := &endpoints.ResolveParam{
Domain: request.GetDomain(),
Product: request.GetProduct(),
RegionId: regionId,
LocationProduct: request.GetLocationServiceCode(),
LocationEndpointType: request.GetLocationEndpointType(),
CommonApi: client.ProcessCommonRequest,
}
endpoint, err = endpoints.Resolve(resolveParam)
if err != nil {
return
}
}
request.SetDomain(endpoint)
if request.GetScheme() == "" {
request.SetScheme(client.config.Scheme)
}
@@ -236,36 +427,233 @@ func (client *Client) DoActionWithSigner(request requests.AcsRequest, response r
} else {
finalSigner = client.signer
}
httpRequest, err := buildHttpRequest(request, finalSigner, regionId)
if client.config.UserAgent != "" {
httpRequest.Header.Set("User-Agent", client.config.UserAgent)
httpRequest, err = buildHttpRequest(request, finalSigner, regionId)
if err == nil {
userAgent := DefaultUserAgent + getSendUserAgent(client.config.UserAgent, client.userAgent, request.GetUserAgent())
httpRequest.Header.Set("User-Agent", userAgent)
}
return
}
func getSendUserAgent(configUserAgent string, clientUserAgent, requestUserAgent map[string]string) string {
realUserAgent := ""
for key1, value1 := range clientUserAgent {
for key2, _ := range requestUserAgent {
if key1 == key2 {
key1 = ""
}
}
if key1 != "" {
realUserAgent += fmt.Sprintf(" %s/%s", key1, value1)
}
}
for key, value := range requestUserAgent {
realUserAgent += fmt.Sprintf(" %s/%s", key, value)
}
if configUserAgent != "" {
return realUserAgent + fmt.Sprintf(" Extra/%s", configUserAgent)
}
return realUserAgent
}
func (client *Client) AppendUserAgent(key, value string) {
newkey := true
if client.userAgent == nil {
client.userAgent = make(map[string]string)
}
if strings.ToLower(key) != "core" && strings.ToLower(key) != "go" {
for tag, _ := range client.userAgent {
if tag == key {
client.userAgent[tag] = value
newkey = false
}
}
if newkey {
client.userAgent[key] = value
}
}
}
func (client *Client) BuildRequestWithSigner(request requests.AcsRequest, signer auth.Signer) (err error) {
_, err = client.buildRequestWithSigner(request, signer)
return
}
func (client *Client) getTimeout(request requests.AcsRequest) (time.Duration, time.Duration) {
readTimeout := defaultReadTimeout
connectTimeout := defaultConnectTimeout
reqReadTimeout := request.GetReadTimeout()
reqConnectTimeout := request.GetConnectTimeout()
if reqReadTimeout != 0*time.Millisecond {
readTimeout = reqReadTimeout
} else if client.readTimeout != 0*time.Millisecond {
readTimeout = client.readTimeout
} else if client.httpClient.Timeout != 0 {
readTimeout = client.httpClient.Timeout
} else if timeout, ok := getAPIMaxTimeout(request.GetProduct(), request.GetActionName()); ok {
readTimeout = timeout
}
if reqConnectTimeout != 0*time.Millisecond {
connectTimeout = reqConnectTimeout
} else if client.connectTimeout != 0*time.Millisecond {
connectTimeout = client.connectTimeout
}
return readTimeout, connectTimeout
}
func Timeout(connectTimeout time.Duration) func(cxt context.Context, net, addr string) (c net.Conn, err error) {
return func(ctx context.Context, network, address string) (net.Conn, error) {
return (&net.Dialer{
Timeout: connectTimeout,
DualStack: true,
}).DialContext(ctx, network, address)
}
}
func (client *Client) setTimeout(request requests.AcsRequest) {
readTimeout, connectTimeout := client.getTimeout(request)
client.httpClient.Timeout = readTimeout
if trans, ok := client.httpClient.Transport.(*http.Transport); ok && trans != nil {
trans.DialContext = Timeout(connectTimeout)
client.httpClient.Transport = trans
} else if client.httpClient.Transport == nil {
client.httpClient.Transport = &http.Transport{
DialContext: Timeout(connectTimeout),
}
}
}
func (client *Client) getHTTPSInsecure(request requests.AcsRequest) (insecure bool) {
if request.GetHTTPSInsecure() != nil {
insecure = *request.GetHTTPSInsecure()
} else {
insecure = client.GetHTTPSInsecure()
}
return insecure
}
func (client *Client) DoActionWithSigner(request requests.AcsRequest, response responses.AcsResponse, signer auth.Signer) (err error) {
if client.Network != "" {
match, _ := regexp.MatchString("^[a-zA-Z0-9_-]+$", client.Network)
if !match {
return fmt.Errorf("netWork contains invalid characters")
}
}
fieldMap := make(map[string]string)
initLogMsg(fieldMap)
defer func() {
client.printLog(fieldMap, err)
}()
httpRequest, err := client.buildRequestWithSigner(request, signer)
if err != nil {
return
}
client.setTimeout(request)
proxy, err := client.getHttpProxy(httpRequest.URL.Scheme)
if err != nil {
return err
}
noProxy := client.getNoProxy(httpRequest.URL.Scheme)
var flag bool
for _, value := range noProxy {
if strings.HasPrefix(value, "*") {
value = fmt.Sprintf(".%s", value)
}
noProxyReg, err := regexp.Compile(value)
if err != nil {
return err
}
if noProxyReg.MatchString(httpRequest.Host) {
flag = true
break
}
}
// Set whether to ignore certificate validation.
// Default InsecureSkipVerify is false.
if trans, ok := client.httpClient.Transport.(*http.Transport); ok && trans != nil {
if trans.TLSClientConfig != nil {
trans.TLSClientConfig.InsecureSkipVerify = client.getHTTPSInsecure(request)
} else {
trans.TLSClientConfig = &tls.Config{
InsecureSkipVerify: client.getHTTPSInsecure(request),
}
}
if proxy != nil && !flag {
trans.Proxy = http.ProxyURL(proxy)
}
client.httpClient.Transport = trans
}
var httpResponse *http.Response
for retryTimes := 0; retryTimes <= client.config.MaxRetryTime; retryTimes++ {
httpResponse, err = client.httpClient.Do(httpRequest)
if proxy != nil && proxy.User != nil {
if password, passwordSet := proxy.User.Password(); passwordSet {
httpRequest.SetBasicAuth(proxy.User.Username(), password)
}
}
if retryTimes > 0 {
client.printLog(fieldMap, err)
initLogMsg(fieldMap)
}
putMsgToMap(fieldMap, httpRequest)
debug("> %s %s %s", httpRequest.Method, httpRequest.URL.RequestURI(), httpRequest.Proto)
debug("> Host: %s", httpRequest.Host)
for key, value := range httpRequest.Header {
debug("> %s: %v", key, strings.Join(value, ""))
}
debug(">")
debug(" Retry Times: %d.", retryTimes)
//var timeout bool
startTime := time.Now()
fieldMap["{start_time}"] = startTime.Format("2006-01-02 15:04:05")
httpResponse, err = hookDo(client.httpClient.Do)(httpRequest)
fieldMap["{cost}"] = time.Now().Sub(startTime).String()
if err == nil {
fieldMap["{code}"] = strconv.Itoa(httpResponse.StatusCode)
fieldMap["{res_headers}"] = TransToString(httpResponse.Header)
debug("< %s %s", httpResponse.Proto, httpResponse.Status)
for key, value := range httpResponse.Header {
debug("< %s: %v", key, strings.Join(value, ""))
}
}
debug("<")
// receive error
if err != nil {
debug(" Error: %s.", err.Error())
if !client.config.AutoRetry {
return
//} else if timeout = isTimeout(err); !timeout {
// // if not timeout error, return
// return
} else if retryTimes >= client.config.MaxRetryTime {
// timeout but reached the max retry times, return
timeoutErrorMsg := fmt.Sprintf(errors.TimeoutErrorMessage, strconv.Itoa(retryTimes+1), strconv.Itoa(retryTimes+1))
times := strconv.Itoa(retryTimes + 1)
timeoutErrorMsg := fmt.Sprintf(errors.TimeoutErrorMessage, times, times)
if strings.Contains(err.Error(), "Client.Timeout") {
timeoutErrorMsg += " Read timeout. Please set a valid ReadTimeout."
} else {
timeoutErrorMsg += " Connect timeout. Please set a valid ConnectTimeout."
}
err = errors.NewClientError(errors.TimeoutErrorCode, timeoutErrorMsg, err)
return
}
}
if isCertificateError(err) {
return
}
// if status code >= 500 or timeout, will trigger retry
if client.config.AutoRetry && (err != nil || isServerError(httpResponse)) {
client.setTimeout(request)
// rewrite signatureNonce and signature
httpRequest, err = buildHttpRequest(request, finalSigner, regionId)
httpRequest, err = client.buildRequestWithSigner(request, signer)
// buildHttpRequest(request, finalSigner, regionId)
if err != nil {
return
}
@@ -273,7 +661,10 @@ func (client *Client) DoActionWithSigner(request requests.AcsRequest, response r
}
break
}
err = responses.Unmarshal(response, httpResponse, request.GetAcceptFormat())
fieldMap["{res_body}"] = response.GetHttpContentString()
debug("%s", response.GetHttpContentString())
// wrap server errors
if serverErr, ok := err.(*errors.ServerError); ok {
var wrapInfo = map[string]string{}
@@ -283,6 +674,25 @@ func (client *Client) DoActionWithSigner(request requests.AcsRequest, response r
return
}
func isCertificateError(err error) bool {
if err != nil && strings.Contains(err.Error(), "x509: certificate signed by unknown authority") {
return true
}
return false
}
func putMsgToMap(fieldMap map[string]string, request *http.Request) {
fieldMap["{host}"] = request.Host
fieldMap["{method}"] = request.Method
fieldMap["{uri}"] = request.URL.RequestURI()
fieldMap["{pid}"] = strconv.Itoa(os.Getpid())
fieldMap["{version}"] = strings.Split(request.Proto, "/")[1]
hostname, _ := os.Hostname()
fieldMap["{hostname}"] = hostname
fieldMap["{req_headers}"] = TransToString(request.Header)
fieldMap["{target}"] = request.URL.Path + request.URL.RawQuery
}
func buildHttpRequest(request requests.AcsRequest, singer auth.Signer, regionId string) (httpRequest *http.Request, err error) {
err = auth.Sign(request, singer, regionId)
if err != nil {
@@ -305,14 +715,6 @@ func buildHttpRequest(request requests.AcsRequest, singer auth.Signer, regionId
return
}
func isTimeout(err error) bool {
if err == nil {
return false
}
netErr, isNetError := err.(net.Error)
return isNetError && netErr.Timeout()
}
func isServerError(httpResponse *http.Response) bool {
return httpResponse.StatusCode >= http.StatusInternalServerError
}
@@ -339,12 +741,32 @@ func (client *Client) GetConfig() *Config {
return client.config
}
func (client *Client) GetSigner() auth.Signer {
return client.signer
}
func (client *Client) SetSigner(signer auth.Signer) {
client.signer = signer
}
func NewClient() (client *Client, err error) {
client = &Client{}
err = client.Init()
return
}
func NewClientWithProvider(regionId string, providers ...provider.Provider) (client *Client, err error) {
client = &Client{}
var pc provider.Provider
if len(providers) == 0 {
pc = provider.DefaultChain
} else {
pc = provider.NewProviderChain(providers)
}
err = client.InitWithProviderChain(regionId, pc)
return
}
func NewClientWithOptions(regionId string, config *Config, credential auth.Credential) (client *Client, err error) {
client = &Client{}
err = client.InitWithOptions(regionId, config, credential)
@@ -369,6 +791,12 @@ func NewClientWithRamRoleArn(regionId string, accessKeyId, accessKeySecret, role
return
}
func NewClientWithRamRoleArnAndPolicy(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string) (client *Client, err error) {
client = &Client{}
err = client.InitWithRamRoleArnAndPolicy(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy)
return
}
func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client, err error) {
client = &Client{}
err = client.InitWithEcsRamRole(regionId, roleName)
@@ -381,14 +809,10 @@ func NewClientWithRsaKeyPair(regionId string, publicKeyId, privateKey string, se
return
}
// Deprecated: Use NewClientWithRamRoleArn in this package instead.
func NewClientWithStsRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) {
return NewClientWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName)
}
// Deprecated: Use NewClientWithEcsRamRole in this package instead.
func NewClientWithStsRoleNameOnEcs(regionId string, roleName string) (client *Client, err error) {
return NewClientWithEcsRamRole(regionId, roleName)
func NewClientWithBearerToken(regionId, bearerToken string) (client *Client, err error) {
client = &Client{}
err = client.InitWithBearerToken(regionId, bearerToken)
return
}
func (client *Client) ProcessCommonRequest(request *requests.CommonRequest) (response *responses.CommonResponse, err error) {
@@ -404,16 +828,27 @@ func (client *Client) ProcessCommonRequestWithSigner(request *requests.CommonReq
response = responses.NewCommonResponse()
err = client.DoActionWithSigner(request, response, signer)
return
} else {
panic("should not be here")
}
panic("should not be here")
}
func (client *Client) Shutdown() {
client.signer.Shutdown()
// lock the addAsync()
client.asyncChanLock.Lock()
defer client.asyncChanLock.Unlock()
if client.asyncTaskQueue != nil {
close(client.asyncTaskQueue)
}
client.isRunning = false
close(client.asyncTaskQueue)
client.isOpenAsync = false
}
// Deprecated: Use NewClientWithRamRoleArn in this package instead.
func NewClientWithStsRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) {
return NewClientWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName)
}
// Deprecated: Use NewClientWithEcsRamRole in this package instead.
func NewClientWithStsRoleNameOnEcs(regionId string, roleName string) (client *Client, err error) {
return NewClientWithEcsRamRole(regionId, roleName)
}

View File

@@ -15,22 +15,24 @@
package sdk
import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
"net/http"
"time"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
)
type Config struct {
AutoRetry bool `default:"true"`
MaxRetryTime int `default:"3"`
UserAgent string `default:""`
Debug bool `default:"false"`
Timeout time.Duration `default:"10000000000"`
HttpTransport *http.Transport `default:""`
EnableAsync bool `default:"false"`
MaxTaskQueueSize int `default:"1000"`
GoRoutinePoolSize int `default:"5"`
Scheme string `default:"HTTP"`
AutoRetry bool `default:"true"`
MaxRetryTime int `default:"3"`
UserAgent string `default:""`
Debug bool `default:"false"`
HttpTransport *http.Transport `default:""`
Transport http.RoundTripper `default:""`
EnableAsync bool `default:"false"`
MaxTaskQueueSize int `default:"1000"`
GoRoutinePoolSize int `default:"5"`
Scheme string `default:"HTTP"`
Timeout time.Duration
}
func NewConfig() (config *Config) {
@@ -39,11 +41,6 @@ func NewConfig() (config *Config) {
return
}
func (c *Config) WithTimeout(timeout time.Duration) *Config {
c.Timeout = timeout
return c
}
func (c *Config) WithAutoRetry(isAutoRetry bool) *Config {
c.AutoRetry = isAutoRetry
return c
@@ -59,6 +56,16 @@ func (c *Config) WithUserAgent(userAgent string) *Config {
return c
}
func (c *Config) WithDebug(isDebug bool) *Config {
c.Debug = isDebug
return c
}
func (c *Config) WithTimeout(timeout time.Duration) *Config {
c.Timeout = timeout
return c
}
func (c *Config) WithHttpTransport(httpTransport *http.Transport) *Config {
c.HttpTransport = httpTransport
return c
@@ -79,7 +86,7 @@ func (c *Config) WithGoRoutinePoolSize(goRoutinePoolSize int) *Config {
return c
}
func (c *Config) WithDebug(isDebug bool) *Config {
c.Debug = isDebug
func (c *Config) WithScheme(scheme string) *Config {
c.Scheme = scheme
return c
}

File diff suppressed because it is too large Load Diff

View File

@@ -16,13 +16,19 @@ package endpoints
import (
"fmt"
"github.com/jmespath/go-jmespath"
"strings"
"github.com/jmespath/go-jmespath"
)
type LocalGlobalResolver struct {
}
func (resolver *LocalGlobalResolver) GetName() (name string) {
name = "local global resolver"
return
}
func (resolver *LocalGlobalResolver) TryResolve(param *ResolveParam) (endpoint string, support bool, err error) {
// get the global endpoints configs
endpointExpression := fmt.Sprintf("products[?code=='%s'].global_endpoint", strings.ToLower(param.Product))
@@ -30,7 +36,7 @@ func (resolver *LocalGlobalResolver) TryResolve(param *ResolveParam) (endpoint s
if err == nil && endpointData != nil && len(endpointData.([]interface{})) > 0 {
endpoint = endpointData.([]interface{})[0].(string)
support = len(endpoint) > 0
return endpoint, support, nil
return
}
support = false
return

View File

@@ -16,24 +16,31 @@ package endpoints
import (
"fmt"
"github.com/jmespath/go-jmespath"
"strings"
"github.com/jmespath/go-jmespath"
)
type LocalRegionalResolver struct {
}
func (resolver *LocalRegionalResolver) GetName() (name string) {
name = "local regional resolver"
return
}
func (resolver *LocalRegionalResolver) TryResolve(param *ResolveParam) (endpoint string, support bool, err error) {
// get the regional endpoints configs
regionalExpression := fmt.Sprintf("products[?code=='%s'].regional_endpoints", strings.ToLower(param.Product))
regionalData, err := jmespath.Search(regionalExpression, getEndpointConfigData())
if err == nil && regionalData != nil && len(regionalData.([]interface{})) > 0 {
endpointExpression := fmt.Sprintf("[0][?region=='%s'].endpoint", strings.ToLower(param.RegionId))
endpointData, err := jmespath.Search(endpointExpression, regionalData)
var endpointData interface{}
endpointData, err = jmespath.Search(endpointExpression, regionalData)
if err == nil && endpointData != nil && len(endpointData.([]interface{})) > 0 {
endpoint = endpointData.([]interface{})[0].(string)
support = len(endpoint) > 0
return endpoint, support, nil
return
}
}
support = false

View File

@@ -15,39 +15,51 @@ package endpoints
import (
"encoding/json"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"sync"
"time"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
)
const (
// EndpointCacheExpireTime ...
EndpointCacheExpireTime = 3600 //Seconds
)
// Cache caches endpoint for specific product and region
type Cache struct {
sync.RWMutex
cache map[string]interface{}
}
func (c Cache) Get(k string) (v interface{}) {
// Get ...
func (c *Cache) Get(k string) (v interface{}) {
c.RLock()
v = c.cache[k]
c.RUnlock()
return
}
func (c Cache) Set(k string, v interface{}) {
// Set ...
func (c *Cache) Set(k string, v interface{}) {
c.Lock()
c.cache[k] = v
c.Unlock()
}
var lastClearTimePerProduct = Cache{cache: make(map[string]interface{})}
var endpointCache = Cache{cache: make(map[string]interface{})}
var lastClearTimePerProduct = &Cache{cache: make(map[string]interface{})}
var endpointCache = &Cache{cache: make(map[string]interface{})}
// LocationResolver ...
type LocationResolver struct {
}
func (resolver *LocationResolver) GetName() (name string) {
name = "location resolver"
return
}
// TryResolve resolves endpoint giving product and region
func (resolver *LocationResolver) TryResolve(param *ResolveParam) (endpoint string, support bool, err error) {
if len(param.LocationProduct) <= 0 {
support = false
@@ -56,8 +68,10 @@ func (resolver *LocationResolver) TryResolve(param *ResolveParam) (endpoint stri
//get from cache
cacheKey := param.Product + "#" + param.RegionId
if endpointCache.cache != nil && len(endpointCache.Get(cacheKey).(string)) > 0 && !CheckCacheIsExpire(cacheKey) {
endpoint = endpointCache.Get(cacheKey).(string)
var ok bool
endpoint, ok = endpointCache.Get(cacheKey).(string)
if ok && len(endpoint) > 0 && !CheckCacheIsExpire(cacheKey) {
support = true
return
}
@@ -81,13 +95,23 @@ func (resolver *LocationResolver) TryResolve(param *ResolveParam) (endpoint stri
}
response, err := param.CommonApi(getEndpointRequest)
var getEndpointResponse GetEndpointResponse
if err != nil {
support = false
return
}
if !response.IsSuccess() {
support = false
return
}
json.Unmarshal([]byte(response.GetHttpContentString()), &getEndpointResponse)
var getEndpointResponse GetEndpointResponse
err = json.Unmarshal([]byte(response.GetHttpContentString()), &getEndpointResponse)
if err != nil {
support = false
return
}
if !getEndpointResponse.Success || getEndpointResponse.Endpoints == nil {
support = false
return
@@ -108,8 +132,13 @@ func (resolver *LocationResolver) TryResolve(param *ResolveParam) (endpoint stri
return
}
// CheckCacheIsExpire ...
func CheckCacheIsExpire(cacheKey string) bool {
lastClearTime := lastClearTimePerProduct.Get(cacheKey).(int64)
lastClearTime, ok := lastClearTimePerProduct.Get(cacheKey).(int64)
if !ok {
return true
}
if lastClearTime <= 0 {
lastClearTime = time.Now().Unix()
lastClearTimePerProduct.Set(cacheKey, lastClearTime)
@@ -124,18 +153,21 @@ func CheckCacheIsExpire(cacheKey string) bool {
return false
}
// GetEndpointResponse ...
type GetEndpointResponse struct {
Endpoints *EndpointsObj
RequestId string
Success bool
}
// EndpointsObj ...
type EndpointsObj struct {
Endpoint []EndpointObj
}
// EndpointObj ...
type EndpointObj struct {
Protocols map[string]string
// Protocols map[string]string
Type string
Namespace string
Id string

View File

@@ -17,23 +17,33 @@ package endpoints
import (
"fmt"
"strings"
"sync"
)
const keyFormatter = "%s::%s"
var endpointMapping = make(map[string]string)
type EndpointMapping struct {
sync.RWMutex
endpoint map[string]string
}
var endpointMapping = EndpointMapping{endpoint: make(map[string]string)}
// AddEndpointMapping use productId and regionId as key to store the endpoint into inner map
// when using the same productId and regionId as key, the endpoint will be covered.
func AddEndpointMapping(regionId, productId, endpoint string) (err error) {
key := fmt.Sprintf(keyFormatter, strings.ToLower(regionId), strings.ToLower(productId))
endpointMapping[key] = endpoint
endpointMapping.Lock()
endpointMapping.endpoint[key] = endpoint
endpointMapping.Unlock()
return nil
}
type MappingResolver struct {
}
func (resolver *MappingResolver) TryResolve(param *ResolveParam) (endpoint string, support bool, err error) {
key := fmt.Sprintf(keyFormatter, strings.ToLower(param.RegionId), strings.ToLower(param.Product))
endpoint, contains := endpointMapping[key]
return endpoint, contains, nil
// GetEndpointFromMap use Product and RegionId as key to find endpoint from inner map
func GetEndpointFromMap(regionId, productId string) string {
key := fmt.Sprintf(keyFormatter, strings.ToLower(regionId), strings.ToLower(productId))
endpointMapping.RLock()
endpoint := endpointMapping.endpoint[key]
endpointMapping.RUnlock()
return endpoint
}

View File

@@ -17,12 +17,20 @@ package endpoints
import (
"encoding/json"
"fmt"
"sync"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
"sync"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
)
var debug utils.Debug
func init() {
debug = utils.Init("sdk")
}
const (
ResolveEndpointUserGuideLink = ""
)
@@ -32,28 +40,36 @@ var resolvers []Resolver
type Resolver interface {
TryResolve(param *ResolveParam) (endpoint string, support bool, err error)
GetName() (name string)
}
// Resolve resolve endpoint with params
// It will resolve with each supported resolver until anyone resolved
func Resolve(param *ResolveParam) (endpoint string, err error) {
supportedResolvers := getAllResolvers()
var lastErr error
for _, resolver := range supportedResolvers {
endpoint, supported, err := resolver.TryResolve(param)
endpoint, supported, resolveErr := resolver.TryResolve(param)
if resolveErr != nil {
lastErr = resolveErr
}
if supported {
return endpoint, err
debug("resolve endpoint with %s\n", param)
debug("\t%s by resolver(%s)\n", endpoint, resolver.GetName())
return endpoint, nil
}
}
// not support
errorMsg := fmt.Sprintf(errors.CanNotResolveEndpointErrorMessage, param, ResolveEndpointUserGuideLink)
err = errors.NewClientError(errors.CanNotResolveEndpointErrorCode, errorMsg, nil)
err = errors.NewClientError(errors.CanNotResolveEndpointErrorCode, errorMsg, lastErr)
return
}
func getAllResolvers() []Resolver {
once.Do(func() {
resolvers = []Resolver{
&SimpleHostResolver{},
&MappingResolver{},
&LocationResolver{},
&LocalRegionalResolver{},
&LocalGlobalResolver{},

View File

@@ -1,25 +0,0 @@
/*
* 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 endpoints
type SimpleHostResolver struct {
}
func (resolver *SimpleHostResolver) TryResolve(param *ResolveParam) (endpoint string, support bool, err error) {
if support = len(param.Domain) > 0; support {
endpoint = param.Domain
}
return
}

View File

@@ -60,7 +60,7 @@ func NewClientError(errorCode, message string, originErr error) Error {
}
func (err *ClientError) Error() string {
clientErrMsg := fmt.Sprintf("[%s] %s", err.errorCode, err.message)
clientErrMsg := fmt.Sprintf("[%s] %s", err.ErrorCode(), err.message)
if err.originError != nil {
return clientErrMsg + "\ncaused by:\n" + err.originError.Error()
}

View File

@@ -17,6 +17,7 @@ package errors
import (
"encoding/json"
"fmt"
"github.com/jmespath/go-jmespath"
)
@@ -35,7 +36,7 @@ type ServerError struct {
}
type ServerErrorWrapper interface {
tryWrap(error *ServerError, wrapInfo map[string]string) (bool, *ServerError)
tryWrap(error *ServerError, wrapInfo map[string]string) bool
}
func (err *ServerError) Error() string {
@@ -81,9 +82,9 @@ func NewServerError(httpStatus int, responseContent, comment string) Error {
func WrapServerError(originError *ServerError, wrapInfo map[string]string) *ServerError {
for _, wrapper := range wrapperList {
ok, newError := wrapper.tryWrap(originError, wrapInfo)
ok := wrapper.tryWrap(originError, wrapInfo)
if ok {
return newError
return originError
}
}
return originError

View File

@@ -1,29 +1,45 @@
package errors
import "strings"
import (
"strings"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
)
const SignatureDostNotMatchErrorCode = "SignatureDoesNotMatch"
const MessagePrefix = "Specified signature is not matched with our calculation. server string to sign is:"
const IncompleteSignatureErrorCode = "IncompleteSignature"
const MessageContain = "server string to sign is:"
var debug utils.Debug
func init() {
debug = utils.Init("sdk")
}
type SignatureDostNotMatchWrapper struct {
}
func (*SignatureDostNotMatchWrapper) tryWrap(error *ServerError, wrapInfo map[string]string) (bool, *ServerError) {
func (*SignatureDostNotMatchWrapper) tryWrap(error *ServerError, wrapInfo map[string]string) (ok bool) {
clientStringToSign := wrapInfo["StringToSign"]
if error.errorCode == SignatureDostNotMatchErrorCode && clientStringToSign != "" {
if (error.errorCode == SignatureDostNotMatchErrorCode || error.errorCode == IncompleteSignatureErrorCode) && clientStringToSign != "" {
message := error.message
if strings.HasPrefix(message, MessagePrefix) {
serverStringToSign := message[len(MessagePrefix):]
if strings.Contains(message, MessageContain) {
str := strings.Split(message, MessageContain)
serverStringToSign := str[1]
if clientStringToSign == serverStringToSign {
// user secret is error
error.recommend = "Please check you AccessKeySecret"
error.recommend = "InvalidAccessKeySecret: Please check you AccessKeySecret"
} else {
debug("Client StringToSign: %s", clientStringToSign)
debug("Server StringToSign: %s", serverStringToSign)
error.recommend = "This may be a bug with the SDK and we hope you can submit this question in the " +
"github issue(https://github.com/aliyun/alibaba-cloud-sdk-go/issues), thanks very much"
}
}
return true, error
} else {
return false, nil
ok = true
return
}
ok = false
return
}

View File

@@ -0,0 +1,116 @@
package sdk
import (
"encoding/json"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
"io"
"log"
"os"
"strings"
"time"
)
var logChannel string
var defaultChannel = "AlibabaCloud"
type Logger struct {
*log.Logger
formatTemplate string
isOpen bool
lastLogMsg string
}
var defaultLoggerTemplate = `{time} {channel}: "{method} {uri} HTTP/{version}" {code} {cost} {hostname}`
var loggerParam = []string{"{time}", "{start_time}", "{ts}", "{channel}", "{pid}", "{host}", "{method}", "{uri}", "{version}", "{target}", "{hostname}", "{code}", "{error}", "{req_headers}", "{res_body}", "{res_headers}", "{cost}"}
func initLogMsg(fieldMap map[string]string) {
for _, value := range loggerParam {
fieldMap[value] = ""
}
}
func (client *Client) GetLogger() *Logger {
return client.logger
}
func (client *Client) GetLoggerMsg() string {
if client.logger == nil {
client.SetLogger("", "", os.Stdout, "")
}
return client.logger.lastLogMsg
}
func (client *Client) SetLogger(level string, channel string, out io.Writer, template string) {
if level == "" {
level = "info"
}
logChannel = "AlibabaCloud"
if channel != "" {
logChannel = channel
}
log := log.New(out, "["+strings.ToUpper(level)+"]", log.Lshortfile)
if template == "" {
template = defaultLoggerTemplate
}
client.logger = &Logger{
Logger: log,
formatTemplate: template,
isOpen: true,
}
}
func (client *Client) OpenLogger() {
if client.logger == nil {
client.SetLogger("", "", os.Stdout, "")
}
client.logger.isOpen = true
}
func (client *Client) CloseLogger() {
if client.logger != nil {
client.logger.isOpen = false
}
}
func (client *Client) SetTemplate(template string) {
if client.logger == nil {
client.SetLogger("", "", os.Stdout, "")
}
client.logger.formatTemplate = template
}
func (client *Client) GetTemplate() string {
if client.logger == nil {
client.SetLogger("", "", os.Stdout, "")
}
return client.logger.formatTemplate
}
func TransToString(object interface{}) string {
byt, err := json.Marshal(object)
if err != nil {
return ""
}
return string(byt)
}
func (client *Client) printLog(fieldMap map[string]string, err error) {
if err != nil {
fieldMap["{error}"] = err.Error()
}
fieldMap["{time}"] = time.Now().Format("2006-01-02 15:04:05")
fieldMap["{ts}"] = utils.GetTimeInFormatISO8601()
fieldMap["{channel}"] = logChannel
if client.logger != nil {
logMsg := client.logger.formatTemplate
for key, value := range fieldMap {
logMsg = strings.Replace(logMsg, key, value, -1)
}
client.logger.lastLogMsg = logMsg
if client.logger.isOpen == true {
client.logger.Output(2, logMsg)
}
}
}

View File

@@ -15,11 +15,15 @@
package requests
import (
"encoding/json"
"fmt"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
"io"
"reflect"
"strconv"
"strings"
"time"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
)
const (
@@ -35,6 +39,7 @@ const (
PUT = "PUT"
POST = "POST"
DELETE = "DELETE"
PATCH = "PATCH"
HEAD = "HEAD"
OPTIONS = "OPTIONS"
@@ -58,8 +63,6 @@ type AcsRequest interface {
GetDomain() string
GetPort() string
GetRegionId() string
GetUrl() string
GetQueries() string
GetHeaders() map[string]string
GetQueryParams() map[string]string
GetFormParams() map[string]string
@@ -68,10 +71,19 @@ type AcsRequest interface {
GetStyle() string
GetProduct() string
GetVersion() string
SetVersion(version string)
GetActionName() string
GetAcceptFormat() string
GetLocationServiceCode() string
GetLocationEndpointType() string
GetReadTimeout() time.Duration
GetConnectTimeout() time.Duration
SetReadTimeout(readTimeout time.Duration)
SetConnectTimeout(connectTimeout time.Duration)
SetHTTPSInsecure(isInsecure bool)
GetHTTPSInsecure() *bool
GetUserAgent() map[string]string
SetStringToSign(stringToSign string)
GetStringToSign() string
@@ -90,14 +102,18 @@ type AcsRequest interface {
// base class
type baseRequest struct {
Scheme string
Method string
Domain string
Port string
RegionId string
Scheme string
Method string
Domain string
Port string
RegionId string
ReadTimeout time.Duration
ConnectTimeout time.Duration
isInsecure *bool
product string
version string
userAgent map[string]string
product string
version string
actionName string
@@ -124,10 +140,38 @@ func (request *baseRequest) GetFormParams() map[string]string {
return request.FormParams
}
func (request *baseRequest) GetReadTimeout() time.Duration {
return request.ReadTimeout
}
func (request *baseRequest) GetConnectTimeout() time.Duration {
return request.ConnectTimeout
}
func (request *baseRequest) SetReadTimeout(readTimeout time.Duration) {
request.ReadTimeout = readTimeout
}
func (request *baseRequest) SetConnectTimeout(connectTimeout time.Duration) {
request.ConnectTimeout = connectTimeout
}
func (request *baseRequest) GetHTTPSInsecure() *bool {
return request.isInsecure
}
func (request *baseRequest) SetHTTPSInsecure(isInsecure bool) {
request.isInsecure = &isInsecure
}
func (request *baseRequest) GetContent() []byte {
return request.Content
}
func (request *baseRequest) SetVersion(version string) {
request.version = version
}
func (request *baseRequest) GetVersion() string {
return request.version
}
@@ -140,6 +184,28 @@ func (request *baseRequest) SetContent(content []byte) {
request.Content = content
}
func (request *baseRequest) GetUserAgent() map[string]string {
return request.userAgent
}
func (request *baseRequest) AppendUserAgent(key, value string) {
newkey := true
if request.userAgent == nil {
request.userAgent = make(map[string]string)
}
if strings.ToLower(key) != "core" && strings.ToLower(key) != "go" {
for tag, _ := range request.userAgent {
if tag == key {
request.userAgent[tag] = value
newkey = false
}
}
if newkey {
request.userAgent[key] = value
}
}
}
func (request *baseRequest) addHeaderParam(key, value string) {
request.Headers[key] = value
}
@@ -201,7 +267,7 @@ func (request *baseRequest) GetHeaders() map[string]string {
}
func (request *baseRequest) SetContentType(contentType string) {
request.Headers["Content-Type"] = contentType
request.addHeaderParam("Content-Type", contentType)
}
func (request *baseRequest) GetContentType() (contentType string, contains bool) {
@@ -226,7 +292,7 @@ func defaultBaseRequest() (request *baseRequest) {
Headers: map[string]string{
"x-sdk-client": "golang/1.0.0",
"x-sdk-invoke-type": "normal",
"Accept-Encoding": "identity",
"Accept-Encoding": "identity",
},
FormParams: make(map[string]string),
}
@@ -254,29 +320,97 @@ func flatRepeatedList(dataValue reflect.Value, request AcsRequest, position, pre
// simple param
key := prefix + name
value := dataValue.Field(i).String()
if dataValue.Field(i).Kind().String() == "map" {
byt, _ := json.Marshal(dataValue.Field(i).Interface())
value = string(byt)
if value == "null" {
value = ""
}
}
err = addParam(request, fieldPosition, key, value)
if err != nil {
return
}
} else if typeTag == "Repeated" {
// repeated param
repeatedFieldValue := dataValue.Field(i)
if repeatedFieldValue.Kind() != reflect.Slice {
// possible value: {"[]string", "*[]struct"}, we must call Elem() in the last condition
repeatedFieldValue = repeatedFieldValue.Elem()
err = handleRepeatedParams(request, dataValue, prefix, name, fieldPosition, i)
if err != nil {
return
}
if repeatedFieldValue.IsValid() && !repeatedFieldValue.IsNil() {
for m := 0; m < repeatedFieldValue.Len(); m++ {
elementValue := repeatedFieldValue.Index(m)
key := prefix + name + "." + strconv.Itoa(m+1)
if elementValue.Type().String() == "string" {
value := elementValue.String()
err = addParam(request, fieldPosition, key, value)
if err != nil {
return
}
} else {
err = flatRepeatedList(elementValue, request, fieldPosition, key+".")
} else if typeTag == "Struct" {
err = handleStruct(request, dataValue, prefix, name, fieldPosition, i)
if err != nil {
return
}
}
}
}
return
}
func handleRepeatedParams(request AcsRequest, dataValue reflect.Value, prefix, name, fieldPosition string, index int) (err error) {
repeatedFieldValue := dataValue.Field(index)
if repeatedFieldValue.Kind() != reflect.Slice {
// possible value: {"[]string", "*[]struct"}, we must call Elem() in the last condition
repeatedFieldValue = repeatedFieldValue.Elem()
}
if repeatedFieldValue.IsValid() && !repeatedFieldValue.IsNil() {
for m := 0; m < repeatedFieldValue.Len(); m++ {
elementValue := repeatedFieldValue.Index(m)
key := prefix + name + "." + strconv.Itoa(m+1)
if elementValue.Type().Kind().String() == "string" {
value := elementValue.String()
err = addParam(request, fieldPosition, key, value)
if err != nil {
return
}
} else {
err = flatRepeatedList(elementValue, request, fieldPosition, key+".")
if err != nil {
return
}
}
}
}
return nil
}
func handleStruct(request AcsRequest, dataValue reflect.Value, prefix, name, fieldPosition string, index int) (err error) {
valueField := dataValue.Field(index)
if valueField.IsValid() && valueField.String() != "" {
valueFieldType := valueField.Type()
for m := 0; m < valueFieldType.NumField(); m++ {
fieldName := valueFieldType.Field(m).Name
elementValue := valueField.FieldByName(fieldName)
key := prefix + name + "." + fieldName
if elementValue.Type().String() == "[]string" {
if elementValue.IsNil() {
continue
}
for j := 0; j < elementValue.Len(); j++ {
err = addParam(request, fieldPosition, key+"."+strconv.Itoa(j+1), elementValue.Index(j).String())
if err != nil {
return
}
}
} else {
if elementValue.Type().Kind().String() == "string" {
value := elementValue.String()
err = addParam(request, fieldPosition, key, value)
if err != nil {
return
}
} else if elementValue.Type().Kind().String() == "struct" {
err = flatRepeatedList(elementValue, request, fieldPosition, key+".")
if err != nil {
return
}
} else if !elementValue.IsNil() {
repeatedFieldValue := elementValue.Elem()
if repeatedFieldValue.IsValid() && !repeatedFieldValue.IsNil() {
for m := 0; m < repeatedFieldValue.Len(); m++ {
elementValue := repeatedFieldValue.Index(m)
err = flatRepeatedList(elementValue, request, fieldPosition, key+"."+strconv.Itoa(m+1)+".")
if err != nil {
return
}
@@ -286,7 +420,7 @@ func flatRepeatedList(dataValue reflect.Value, request AcsRequest, position, pre
}
}
}
return
return nil
}
func addParam(request AcsRequest, position, name, value string) (err error) {

View File

@@ -3,17 +3,18 @@ package requests
import (
"bytes"
"fmt"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
"io"
"sort"
"strings"
)
type CommonRequest struct {
*baseRequest
Version string
ApiName string
Product string
Version string
ApiName string
Product string
ServiceCode string
// roa params
PathPattern string
@@ -33,22 +34,27 @@ func NewCommonRequest() (request *CommonRequest) {
func (request *CommonRequest) String() string {
request.TransToAcsRequest()
request.BuildQueries()
request.BuildUrl()
resultBuilder := bytes.Buffer{}
mapOutput := func(m map[string]string) {
if len(m) > 0 {
for key, value := range m {
resultBuilder.WriteString(key + ": " + value + "\n")
sortedKeys := make([]string, 0)
for k := range m {
sortedKeys = append(sortedKeys, k)
}
// sort 'string' key in increasing order
sort.Strings(sortedKeys)
for _, key := range sortedKeys {
resultBuilder.WriteString(key + ": " + m[key] + "\n")
}
}
}
// Request Line
resultBuilder.WriteString("\n")
resultBuilder.WriteString(fmt.Sprintf("%s %s %s/1.1\n", request.Method, request.GetQueries(), strings.ToUpper(request.Scheme)))
resultBuilder.WriteString(fmt.Sprintf("%s %s %s/1.1\n", request.Method, request.BuildQueries(), strings.ToUpper(request.Scheme)))
// Headers
resultBuilder.WriteString("Host" + ": " + request.Domain + "\n")
@@ -66,16 +72,6 @@ func (request *CommonRequest) String() string {
}
func (request *CommonRequest) TransToAcsRequest() {
if len(request.Version) == 0 {
errors.NewClientError(errors.MissingParamErrorCode, "Common request [version] is required", nil)
}
if len(request.ApiName) == 0 && len(request.PathPattern) == 0 {
errors.NewClientError(errors.MissingParamErrorCode, "At least one of [ApiName] and [PathPattern] should has a value", nil)
}
if len(request.Domain) == 0 && len(request.Product) == 0 {
errors.NewClientError(errors.MissingParamErrorCode, "At least one of [Domain] and [Product] should has a value", nil)
}
if len(request.PathPattern) > 0 {
roaRequest := &RoaRequest{}
roaRequest.initWithCommonRequest(request)
@@ -85,36 +81,22 @@ func (request *CommonRequest) TransToAcsRequest() {
rpcRequest.baseRequest = request.baseRequest
rpcRequest.product = request.Product
rpcRequest.version = request.Version
rpcRequest.locationServiceCode = request.ServiceCode
rpcRequest.actionName = request.ApiName
rpcRequest.Headers["x-acs-version"] = request.Version
rpcRequest.Headers["x-acs-action"] = request.ApiName
request.Ontology = rpcRequest
}
}
func (request *CommonRequest) BuildUrl() string {
if len(request.Port) > 0 {
return strings.ToLower(request.Scheme) + "://" + request.Domain + ":" + request.Port + request.BuildQueries()
}
return strings.ToLower(request.Scheme) + "://" + request.Domain + request.BuildQueries()
return request.Ontology.BuildUrl()
}
func (request *CommonRequest) BuildQueries() string {
return request.Ontology.BuildQueries()
}
func (request *CommonRequest) GetUrl() string {
if len(request.Port) > 0 {
return strings.ToLower(request.Scheme) + "://" + request.Domain + ":" + request.Port + request.GetQueries()
}
return strings.ToLower(request.Scheme) + "://" + request.Domain + request.GetQueries()
}
func (request *CommonRequest) GetQueries() string {
return request.Ontology.GetQueries()
}
func (request *CommonRequest) GetBodyReader() io.Reader {
return request.Ontology.GetBodyReader()
}

View File

@@ -16,11 +16,13 @@ package requests
import (
"bytes"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
"fmt"
"io"
"net/url"
"sort"
"strings"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
)
type RoaRequest struct {
@@ -44,29 +46,23 @@ func (request *RoaRequest) GetBodyReader() io.Reader {
}
}
func (request *RoaRequest) GetQueries() string {
return request.queries
}
// for sign method, need not url encoded
func (request *RoaRequest) BuildQueries() string {
return request.buildQueries(false)
return request.buildQueries()
}
func (request *RoaRequest) buildQueries(needParamEncode bool) string {
// replace path params with value
func (request *RoaRequest) buildPath() string {
path := request.pathPattern
for key, value := range request.PathParams {
path = strings.Replace(path, "["+key+"]", value, 1)
}
return path
}
func (request *RoaRequest) buildQueries() string {
// replace path params with value
path := request.buildPath()
queryParams := request.QueryParams
// check if path contains params
splitArray := strings.Split(path, "?")
path = splitArray[0]
if len(splitArray) > 1 && len(splitArray[1]) > 0 {
queryParams[splitArray[1]] = ""
}
// sort QueryParams by key
var queryKeys []string
for key := range queryParams {
@@ -85,36 +81,38 @@ func (request *RoaRequest) buildQueries(needParamEncode bool) string {
urlBuilder.WriteString(queryKey)
if value := queryParams[queryKey]; len(value) > 0 {
urlBuilder.WriteString("=")
if needParamEncode {
urlBuilder.WriteString(url.QueryEscape(value))
} else {
urlBuilder.WriteString(value)
}
urlBuilder.WriteString(value)
}
if i < len(queryKeys)-1 {
urlBuilder.WriteString("&")
}
}
result := urlBuilder.String()
result = popStandardUrlencode(result)
request.queries = result
return request.queries
return result
}
func popStandardUrlencode(stringToSign string) (result string) {
result = strings.Replace(stringToSign, "+", "%20", -1)
result = strings.Replace(result, "*", "%2A", -1)
result = strings.Replace(result, "%7E", "~", -1)
return
}
func (request *RoaRequest) GetUrl() string {
return strings.ToLower(request.Scheme) + "://" + request.Domain + ":" + request.Port + request.GetQueries()
func (request *RoaRequest) buildQueryString() string {
queryParams := request.QueryParams
// sort QueryParams by key
q := url.Values{}
for key, value := range queryParams {
q.Add(key, value)
}
return q.Encode()
}
func (request *RoaRequest) BuildUrl() string {
// for network trans, need url encoded
return strings.ToLower(request.Scheme) + "://" + request.Domain + ":" + request.Port + request.buildQueries(true)
scheme := strings.ToLower(request.Scheme)
domain := request.Domain
port := request.Port
path := request.buildPath()
url := fmt.Sprintf("%s://%s:%s%s", scheme, domain, port, path)
querystring := request.buildQueryString()
if len(querystring) > 0 {
url = fmt.Sprintf("%s?%s", url, querystring)
}
return url
}
func (request *RoaRequest) addPathParam(key, value string) {
@@ -125,22 +123,26 @@ func (request *RoaRequest) InitWithApiInfo(product, version, action, uriPattern,
request.baseRequest = defaultBaseRequest()
request.PathParams = make(map[string]string)
request.Headers["x-acs-version"] = version
request.Headers["x-acs-action"] = action
request.pathPattern = uriPattern
request.locationServiceCode = serviceCode
request.locationEndpointType = endpointType
//request.product = product
request.product = product
//request.version = version
//request.actionName = action
request.actionName = action
}
func (request *RoaRequest) initWithCommonRequest(commonRequest *CommonRequest) {
request.baseRequest = commonRequest.baseRequest
request.PathParams = commonRequest.PathParams
//request.product = commonRequest.Product
request.product = commonRequest.Product
//request.version = commonRequest.Version
request.Headers["x-acs-version"] = commonRequest.Version
//request.actionName = commonRequest.ApiName
if commonRequest.ApiName != "" {
request.Headers["x-acs-action"] = commonRequest.ApiName
}
request.actionName = commonRequest.ApiName
request.pathPattern = commonRequest.PathPattern
request.locationServiceCode = ""
request.locationServiceCode = commonRequest.ServiceCode
request.locationEndpointType = ""
}

View File

@@ -15,9 +15,11 @@
package requests
import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
"fmt"
"io"
"strings"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
)
type RpcRequest struct {
@@ -47,16 +49,12 @@ func (request *RpcRequest) BuildQueries() string {
return request.queries
}
func (request *RpcRequest) GetQueries() string {
return request.queries
}
func (request *RpcRequest) BuildUrl() string {
return strings.ToLower(request.Scheme) + "://" + request.Domain + ":" + request.Port + request.BuildQueries()
}
func (request *RpcRequest) GetUrl() string {
return strings.ToLower(request.Scheme) + "://" + request.Domain + request.GetQueries()
url := fmt.Sprintf("%s://%s", strings.ToLower(request.Scheme), request.Domain)
if len(request.Port) > 0 {
url = fmt.Sprintf("%s:%s", url, request.Port)
}
return url + request.BuildQueries()
}
func (request *RpcRequest) GetVersion() string {
@@ -78,4 +76,6 @@ func (request *RpcRequest) InitWithApiInfo(product, version, action, serviceCode
request.actionName = action
request.locationServiceCode = serviceCode
request.locationEndpointType = endpointType
request.Headers["x-acs-version"] = version
request.Headers["x-acs-action"] = action
}

View File

@@ -2,13 +2,15 @@ package responses
import (
"encoding/json"
"github.com/json-iterator/go"
"io"
"math"
"reflect"
"strconv"
"strings"
"sync"
"unsafe"
jsoniter "github.com/json-iterator/go"
"github.com/modern-go/reflect2"
)
const maxUint = ^uint(0)
@@ -16,140 +18,145 @@ const maxInt = int(maxUint >> 1)
const minInt = -maxInt - 1
var jsonParser jsoniter.API
var initJson = &sync.Once{}
func initJsonParserOnce() {
initJson.Do(func() {
registerBetterFuzzyDecoder()
jsonParser = jsoniter.ConfigCompatibleWithStandardLibrary
})
func init() {
jsonParser = jsoniter.Config{
EscapeHTML: true,
SortMapKeys: true,
ValidateJsonRawMessage: true,
CaseSensitive: true,
}.Froze()
jsonParser.RegisterExtension(newBetterFuzzyExtension())
}
func registerBetterFuzzyDecoder() {
jsoniter.RegisterTypeDecoder("string", &nullableFuzzyStringDecoder{})
jsoniter.RegisterTypeDecoder("bool", &fuzzyBoolDecoder{})
jsoniter.RegisterTypeDecoder("float32", &nullableFuzzyFloat32Decoder{})
jsoniter.RegisterTypeDecoder("float64", &nullableFuzzyFloat64Decoder{})
jsoniter.RegisterTypeDecoder("int", &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(maxInt) || val < float64(minInt) {
iter.ReportError("fuzzy decode int", "exceed range")
return
func newBetterFuzzyExtension() jsoniter.DecoderExtension {
return jsoniter.DecoderExtension{
reflect2.DefaultTypeOfKind(reflect.String): &nullableFuzzyStringDecoder{},
reflect2.DefaultTypeOfKind(reflect.Bool): &fuzzyBoolDecoder{},
reflect2.DefaultTypeOfKind(reflect.Float32): &nullableFuzzyFloat32Decoder{},
reflect2.DefaultTypeOfKind(reflect.Float64): &nullableFuzzyFloat64Decoder{},
reflect2.DefaultTypeOfKind(reflect.Int): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(maxInt) || val < float64(minInt) {
iter.ReportError("fuzzy decode int", "exceed range")
return
}
*((*int)(ptr)) = int(val)
} else {
*((*int)(ptr)) = iter.ReadInt()
}
*((*int)(ptr)) = int(val)
} else {
*((*int)(ptr)) = iter.ReadInt()
}
}})
jsoniter.RegisterTypeDecoder("uint", &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(maxUint) || val < 0 {
iter.ReportError("fuzzy decode uint", "exceed range")
return
}},
reflect2.DefaultTypeOfKind(reflect.Uint): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(maxUint) || val < 0 {
iter.ReportError("fuzzy decode uint", "exceed range")
return
}
*((*uint)(ptr)) = uint(val)
} else {
*((*uint)(ptr)) = iter.ReadUint()
}
*((*uint)(ptr)) = uint(val)
} else {
*((*uint)(ptr)) = iter.ReadUint()
}
}})
jsoniter.RegisterTypeDecoder("int8", &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxInt8) || val < float64(math.MinInt8) {
iter.ReportError("fuzzy decode int8", "exceed range")
return
}},
reflect2.DefaultTypeOfKind(reflect.Int8): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxInt8) || val < float64(math.MinInt8) {
iter.ReportError("fuzzy decode int8", "exceed range")
return
}
*((*int8)(ptr)) = int8(val)
} else {
*((*int8)(ptr)) = iter.ReadInt8()
}
*((*int8)(ptr)) = int8(val)
} else {
*((*int8)(ptr)) = iter.ReadInt8()
}
}})
jsoniter.RegisterTypeDecoder("uint8", &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxUint8) || val < 0 {
iter.ReportError("fuzzy decode uint8", "exceed range")
return
}},
reflect2.DefaultTypeOfKind(reflect.Uint8): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxUint8) || val < 0 {
iter.ReportError("fuzzy decode uint8", "exceed range")
return
}
*((*uint8)(ptr)) = uint8(val)
} else {
*((*uint8)(ptr)) = iter.ReadUint8()
}
*((*uint8)(ptr)) = uint8(val)
} else {
*((*uint8)(ptr)) = iter.ReadUint8()
}
}})
jsoniter.RegisterTypeDecoder("int16", &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxInt16) || val < float64(math.MinInt16) {
iter.ReportError("fuzzy decode int16", "exceed range")
return
}},
reflect2.DefaultTypeOfKind(reflect.Int16): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxInt16) || val < float64(math.MinInt16) {
iter.ReportError("fuzzy decode int16", "exceed range")
return
}
*((*int16)(ptr)) = int16(val)
} else {
*((*int16)(ptr)) = iter.ReadInt16()
}
*((*int16)(ptr)) = int16(val)
} else {
*((*int16)(ptr)) = iter.ReadInt16()
}
}})
jsoniter.RegisterTypeDecoder("uint16", &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxUint16) || val < 0 {
iter.ReportError("fuzzy decode uint16", "exceed range")
return
}},
reflect2.DefaultTypeOfKind(reflect.Uint16): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxUint16) || val < 0 {
iter.ReportError("fuzzy decode uint16", "exceed range")
return
}
*((*uint16)(ptr)) = uint16(val)
} else {
*((*uint16)(ptr)) = iter.ReadUint16()
}
*((*uint16)(ptr)) = uint16(val)
} else {
*((*uint16)(ptr)) = iter.ReadUint16()
}
}})
jsoniter.RegisterTypeDecoder("int32", &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxInt32) || val < float64(math.MinInt32) {
iter.ReportError("fuzzy decode int32", "exceed range")
return
}},
reflect2.DefaultTypeOfKind(reflect.Int32): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxInt32) || val < float64(math.MinInt32) {
iter.ReportError("fuzzy decode int32", "exceed range")
return
}
*((*int32)(ptr)) = int32(val)
} else {
*((*int32)(ptr)) = iter.ReadInt32()
}
*((*int32)(ptr)) = int32(val)
} else {
*((*int32)(ptr)) = iter.ReadInt32()
}
}})
jsoniter.RegisterTypeDecoder("uint32", &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxUint32) || val < 0 {
iter.ReportError("fuzzy decode uint32", "exceed range")
return
}},
reflect2.DefaultTypeOfKind(reflect.Uint32): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxUint32) || val < 0 {
iter.ReportError("fuzzy decode uint32", "exceed range")
return
}
*((*uint32)(ptr)) = uint32(val)
} else {
*((*uint32)(ptr)) = iter.ReadUint32()
}
*((*uint32)(ptr)) = uint32(val)
} else {
*((*uint32)(ptr)) = iter.ReadUint32()
}
}})
jsoniter.RegisterTypeDecoder("int64", &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxInt64) || val < float64(math.MinInt64) {
iter.ReportError("fuzzy decode int64", "exceed range")
return
}},
reflect2.DefaultTypeOfKind(reflect.Int64): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxInt64) || val < float64(math.MinInt64) {
iter.ReportError("fuzzy decode int64", "exceed range")
return
}
*((*int64)(ptr)) = int64(val)
} else {
*((*int64)(ptr)) = iter.ReadInt64()
}
*((*int64)(ptr)) = int64(val)
} else {
*((*int64)(ptr)) = iter.ReadInt64()
}
}})
jsoniter.RegisterTypeDecoder("uint64", &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxUint64) || val < 0 {
iter.ReportError("fuzzy decode uint64", "exceed range")
return
}},
reflect2.DefaultTypeOfKind(reflect.Uint64): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if isFloat {
val := iter.ReadFloat64()
if val > float64(math.MaxUint64) || val < 0 {
iter.ReportError("fuzzy decode uint64", "exceed range")
return
}
*((*uint64)(ptr)) = uint64(val)
} else {
*((*uint64)(ptr)) = iter.ReadUint64()
}
*((*uint64)(ptr)) = uint64(val)
} else {
*((*uint64)(ptr)) = iter.ReadUint64()
}
}})
}},
}
}
type nullableFuzzyStringDecoder struct {
@@ -211,21 +218,6 @@ func (decoder *fuzzyBoolDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Itera
}
}
type tolerateEmptyArrayDecoder struct {
valDecoder jsoniter.ValDecoder
}
func (decoder *tolerateEmptyArrayDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator) {
if iter.WhatIsNext() == jsoniter.ArrayValue {
iter.Skip()
newIter := iter.Pool().BorrowIterator([]byte("{}"))
defer iter.Pool().ReturnIterator(newIter)
decoder.valDecoder.Decode(ptr, newIter)
} else {
decoder.valDecoder.Decode(ptr, iter)
}
}
type nullableFuzzyIntegerDecoder struct {
fun func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator)
}
@@ -336,6 +328,6 @@ func (decoder *nullableFuzzyFloat64Decoder) Decode(ptr unsafe.Pointer, iter *jso
iter.ReadNil()
*((*float64)(ptr)) = 0
default:
iter.ReportError("nullableFuzzyFloat32Decoder", "not number or string")
iter.ReportError("nullableFuzzyFloat64Decoder", "not number or string")
}
}

View File

@@ -18,10 +18,11 @@ import (
"bytes"
"encoding/xml"
"fmt"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
"io/ioutil"
"net/http"
"strings"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
)
type AcsResponse interface {
@@ -34,6 +35,7 @@ type AcsResponse interface {
parseFromHttpResponse(httpResponse *http.Response) error
}
// Unmarshal object from http response body to target Response
func Unmarshal(response AcsResponse, httpResponse *http.Response, format string) (err error) {
err = response.parseFromHttpResponse(httpResponse)
if err != nil {
@@ -43,7 +45,8 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string)
err = errors.NewServerError(response.GetHttpStatus(), response.GetHttpContentString(), "")
return
}
if _, isCommonResponse := response.(CommonResponse); isCommonResponse {
if _, isCommonResponse := response.(*CommonResponse); isCommonResponse {
// common response need not unmarshal
return
}
@@ -53,7 +56,6 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string)
}
if strings.ToUpper(format) == "JSON" {
initJsonParserOnce()
err = jsonParser.Unmarshal(response.GetHttpContentBytes(), response)
if err != nil {
err = errors.NewClientError(errors.JsonUnmarshalErrorCode, errors.JsonUnmarshalErrorMessage, err)
@@ -117,7 +119,7 @@ func (baseResponse *BaseResponse) parseFromHttpResponse(httpResponse *http.Respo
func (baseResponse *BaseResponse) String() string {
resultBuilder := bytes.Buffer{}
// statusCode
resultBuilder.WriteString("\n")
// resultBuilder.WriteString("\n")
resultBuilder.WriteString(fmt.Sprintf("%s %s\n", baseResponse.originHttpResponse.Proto, baseResponse.originHttpResponse.Status))
// httpHeaders
//resultBuilder.WriteString("Headers:\n")

View File

@@ -0,0 +1,36 @@
package utils
import (
"fmt"
"os"
"strings"
)
type Debug func(format string, v ...interface{})
var hookGetEnv = func() string {
return os.Getenv("DEBUG")
}
var hookPrint = func(input string) {
fmt.Println(input)
}
func Init(flag string) Debug {
enable := false
env := hookGetEnv()
parts := strings.Split(env, ",")
for _, part := range parts {
if part == flag {
enable = true
break
}
}
return func(format string, v ...interface{}) {
if enable {
hookPrint(fmt.Sprintf(format, v...))
}
}
}

View File

@@ -16,27 +16,35 @@ package utils
import (
"crypto/md5"
"crypto/rand"
"encoding/base64"
"encoding/hex"
"encoding/json"
"fmt"
"github.com/satori/go.uuid"
"hash"
rand2 "math/rand"
"net/url"
"reflect"
"strconv"
"time"
)
// if you use go 1.10 or higher, you can hack this util by these to avoid "TimeZone.zip not found" on Windows
var LoadLocationFromTZData func(name string, data []byte) (*time.Location, error) = nil
var TZData []byte = nil
type UUID [16]byte
func GetUUIDV4() (uuidHex string) {
uuidV4 := uuid.NewV4()
uuidHex = hex.EncodeToString(uuidV4.Bytes())
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
func GetUUID() (uuidHex string) {
uuid := NewUUID()
uuidHex = hex.EncodeToString(uuid[:])
return
}
func RandStringBytes(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[rand2.Intn(len(letterBytes))]
}
return string(b)
}
func GetMD5Base64(bytes []byte) (base64Value string) {
md5Ctx := md5.New()
md5Ctx.Write(bytes)
@@ -45,29 +53,15 @@ func GetMD5Base64(bytes []byte) (base64Value string) {
return
}
func GetGMTLocation() (*time.Location, error) {
if LoadLocationFromTZData != nil && TZData != nil {
return LoadLocationFromTZData("GMT", TZData)
} else {
return time.LoadLocation("GMT")
}
}
func GetTimeInFormatISO8601() (timeStr string) {
gmt, err := GetGMTLocation()
gmt := time.FixedZone("GMT", 0)
if err != nil {
panic(err)
}
return time.Now().In(gmt).Format("2006-01-02T15:04:05Z")
}
func GetTimeInFormatRFC2616() (timeStr string) {
gmt, err := GetGMTLocation()
gmt := time.FixedZone("GMT", 0)
if err != nil {
panic(err)
}
return time.Now().In(gmt).Format("Mon, 02 Jan 2006 15:04:05 GMT")
}
@@ -80,17 +74,6 @@ func GetUrlFormedMap(source map[string]string) (urlEncoded string) {
return
}
func GetFromJsonString(jsonString, key string) (result string, err error) {
var responseMap map[string]*json.RawMessage
err = json.Unmarshal([]byte(jsonString), &responseMap)
if err != nil {
return
}
fmt.Println(string(*responseMap[key]))
err = json.Unmarshal(*responseMap[key], &result)
return
}
func InitStructWithDefaultTag(bean interface{}) {
configType := reflect.TypeOf(bean)
for i := 0; i < configType.Elem().NumField(); i++ {
@@ -115,3 +98,44 @@ func InitStructWithDefaultTag(bean interface{}) {
}
}
}
func NewUUID() UUID {
ns := UUID{}
safeRandom(ns[:])
u := newFromHash(md5.New(), ns, RandStringBytes(16))
u[6] = (u[6] & 0x0f) | (byte(2) << 4)
u[8] = (u[8]&(0xff>>2) | (0x02 << 6))
return u
}
func newFromHash(h hash.Hash, ns UUID, name string) UUID {
u := UUID{}
h.Write(ns[:])
h.Write([]byte(name))
copy(u[:], h.Sum(nil))
return u
}
func safeRandom(dest []byte) {
if _, err := rand.Read(dest); err != nil {
panic(err)
}
}
func (u UUID) String() string {
buf := make([]byte, 36)
hex.Encode(buf[0:8], u[0:4])
buf[8] = '-'
hex.Encode(buf[9:13], u[4:6])
buf[13] = '-'
hex.Encode(buf[14:18], u[6:8])
buf[18] = '-'
hex.Encode(buf[19:23], u[8:10])
buf[23] = '-'
hex.Encode(buf[24:], u[10:])
return string(buf)
}

View File

@@ -20,24 +20,21 @@ import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
)
// CancelAgreement invokes the ecs.CancelAgreement API synchronously
// api document: https://help.aliyun.com/api/ecs/cancelagreement.html
func (client *Client) CancelAgreement(request *CancelAgreementRequest) (response *CancelAgreementResponse, err error) {
response = CreateCancelAgreementResponse()
// AcceptInquiredSystemEvent invokes the ecs.AcceptInquiredSystemEvent API synchronously
func (client *Client) AcceptInquiredSystemEvent(request *AcceptInquiredSystemEventRequest) (response *AcceptInquiredSystemEventResponse, err error) {
response = CreateAcceptInquiredSystemEventResponse()
err = client.DoAction(request, response)
return
}
// CancelAgreementWithChan invokes the ecs.CancelAgreement API asynchronously
// api document: https://help.aliyun.com/api/ecs/cancelagreement.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CancelAgreementWithChan(request *CancelAgreementRequest) (<-chan *CancelAgreementResponse, <-chan error) {
responseChan := make(chan *CancelAgreementResponse, 1)
// AcceptInquiredSystemEventWithChan invokes the ecs.AcceptInquiredSystemEvent API asynchronously
func (client *Client) AcceptInquiredSystemEventWithChan(request *AcceptInquiredSystemEventRequest) (<-chan *AcceptInquiredSystemEventResponse, <-chan error) {
responseChan := make(chan *AcceptInquiredSystemEventResponse, 1)
errChan := make(chan error, 1)
err := client.AddAsyncTask(func() {
defer close(responseChan)
defer close(errChan)
response, err := client.CancelAgreement(request)
response, err := client.AcceptInquiredSystemEvent(request)
if err != nil {
errChan <- err
} else {
@@ -52,16 +49,14 @@ func (client *Client) CancelAgreementWithChan(request *CancelAgreementRequest) (
return responseChan, errChan
}
// CancelAgreementWithCallback invokes the ecs.CancelAgreement API asynchronously
// api document: https://help.aliyun.com/api/ecs/cancelagreement.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CancelAgreementWithCallback(request *CancelAgreementRequest, callback func(response *CancelAgreementResponse, err error)) <-chan int {
// AcceptInquiredSystemEventWithCallback invokes the ecs.AcceptInquiredSystemEvent API asynchronously
func (client *Client) AcceptInquiredSystemEventWithCallback(request *AcceptInquiredSystemEventRequest, callback func(response *AcceptInquiredSystemEventResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
var response *CancelAgreementResponse
var response *AcceptInquiredSystemEventResponse
var err error
defer close(result)
response, err = client.CancelAgreement(request)
response, err = client.AcceptInquiredSystemEvent(request)
callback(response, err)
result <- 1
})
@@ -73,34 +68,35 @@ func (client *Client) CancelAgreementWithCallback(request *CancelAgreementReques
return result
}
// CancelAgreementRequest is the request struct for api CancelAgreement
type CancelAgreementRequest struct {
// AcceptInquiredSystemEventRequest is the request struct for api AcceptInquiredSystemEvent
type AcceptInquiredSystemEventRequest struct {
*requests.RpcRequest
EventId string `position:"Query" name:"EventId"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
AgreementType string `position:"Query" name:"AgreementType"`
}
// CancelAgreementResponse is the response struct for api CancelAgreement
type CancelAgreementResponse struct {
// AcceptInquiredSystemEventResponse is the response struct for api AcceptInquiredSystemEvent
type AcceptInquiredSystemEventResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
}
// CreateCancelAgreementRequest creates a request to invoke CancelAgreement API
func CreateCancelAgreementRequest() (request *CancelAgreementRequest) {
request = &CancelAgreementRequest{
// CreateAcceptInquiredSystemEventRequest creates a request to invoke AcceptInquiredSystemEvent API
func CreateAcceptInquiredSystemEventRequest() (request *AcceptInquiredSystemEventRequest) {
request = &AcceptInquiredSystemEventRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CancelAgreement", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AcceptInquiredSystemEvent", "", "")
request.Method = requests.POST
return
}
// CreateCancelAgreementResponse creates a response to parse from CancelAgreement response
func CreateCancelAgreementResponse() (response *CancelAgreementResponse) {
response = &CancelAgreementResponse{
// CreateAcceptInquiredSystemEventResponse creates a response to parse from AcceptInquiredSystemEvent response
func CreateAcceptInquiredSystemEventResponse() (response *AcceptInquiredSystemEventResponse) {
response = &AcceptInquiredSystemEventResponse{
BaseResponse: &responses.BaseResponse{},
}
return

View File

@@ -21,7 +21,6 @@ import (
)
// ActivateRouterInterface invokes the ecs.ActivateRouterInterface API synchronously
// api document: https://help.aliyun.com/api/ecs/activaterouterinterface.html
func (client *Client) ActivateRouterInterface(request *ActivateRouterInterfaceRequest) (response *ActivateRouterInterfaceResponse, err error) {
response = CreateActivateRouterInterfaceResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) ActivateRouterInterface(request *ActivateRouterInterfaceRe
}
// ActivateRouterInterfaceWithChan invokes the ecs.ActivateRouterInterface API asynchronously
// api document: https://help.aliyun.com/api/ecs/activaterouterinterface.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) ActivateRouterInterfaceWithChan(request *ActivateRouterInterfaceRequest) (<-chan *ActivateRouterInterfaceResponse, <-chan error) {
responseChan := make(chan *ActivateRouterInterfaceResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) ActivateRouterInterfaceWithChan(request *ActivateRouterInt
}
// ActivateRouterInterfaceWithCallback invokes the ecs.ActivateRouterInterface API asynchronously
// api document: https://help.aliyun.com/api/ecs/activaterouterinterface.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) ActivateRouterInterfaceWithCallback(request *ActivateRouterInterfaceRequest, callback func(response *ActivateRouterInterfaceResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -93,7 +88,8 @@ func CreateActivateRouterInterfaceRequest() (request *ActivateRouterInterfaceReq
request = &ActivateRouterInterfaceRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "ActivateRouterInterface", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "ActivateRouterInterface", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AddBandwidthPackageIps invokes the ecs.AddBandwidthPackageIps API synchronously
// api document: https://help.aliyun.com/api/ecs/addbandwidthpackageips.html
func (client *Client) AddBandwidthPackageIps(request *AddBandwidthPackageIpsRequest) (response *AddBandwidthPackageIpsResponse, err error) {
response = CreateAddBandwidthPackageIpsResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AddBandwidthPackageIps(request *AddBandwidthPackageIpsRequ
}
// AddBandwidthPackageIpsWithChan invokes the ecs.AddBandwidthPackageIps API asynchronously
// api document: https://help.aliyun.com/api/ecs/addbandwidthpackageips.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AddBandwidthPackageIpsWithChan(request *AddBandwidthPackageIpsRequest) (<-chan *AddBandwidthPackageIpsResponse, <-chan error) {
responseChan := make(chan *AddBandwidthPackageIpsResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AddBandwidthPackageIpsWithChan(request *AddBandwidthPackag
}
// AddBandwidthPackageIpsWithCallback invokes the ecs.AddBandwidthPackageIps API asynchronously
// api document: https://help.aliyun.com/api/ecs/addbandwidthpackageips.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AddBandwidthPackageIpsWithCallback(request *AddBandwidthPackageIpsRequest, callback func(response *AddBandwidthPackageIpsResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,9 +72,9 @@ func (client *Client) AddBandwidthPackageIpsWithCallback(request *AddBandwidthPa
type AddBandwidthPackageIpsRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ClientToken string `position:"Query" name:"ClientToken"`
BandwidthPackageId string `position:"Query" name:"BandwidthPackageId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
ClientToken string `position:"Query" name:"ClientToken"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
IpCount string `position:"Query" name:"IpCount"`
@@ -96,7 +91,8 @@ func CreateAddBandwidthPackageIpsRequest() (request *AddBandwidthPackageIpsReque
request = &AddBandwidthPackageIpsRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AddBandwidthPackageIps", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AddBandwidthPackageIps", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AddTags invokes the ecs.AddTags API synchronously
// api document: https://help.aliyun.com/api/ecs/addtags.html
func (client *Client) AddTags(request *AddTagsRequest) (response *AddTagsResponse, err error) {
response = CreateAddTagsResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AddTags(request *AddTagsRequest) (response *AddTagsRespons
}
// AddTagsWithChan invokes the ecs.AddTags API asynchronously
// api document: https://help.aliyun.com/api/ecs/addtags.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AddTagsWithChan(request *AddTagsRequest) (<-chan *AddTagsResponse, <-chan error) {
responseChan := make(chan *AddTagsResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AddTagsWithChan(request *AddTagsRequest) (<-chan *AddTagsR
}
// AddTagsWithCallback invokes the ecs.AddTags API asynchronously
// api document: https://help.aliyun.com/api/ecs/addtags.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AddTagsWithCallback(request *AddTagsRequest, callback func(response *AddTagsResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,9 +72,9 @@ func (client *Client) AddTagsWithCallback(request *AddTagsRequest, callback func
type AddTagsRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
Tag *[]AddTagsTag `position:"Query" name:"Tag" type:"Repeated"`
ResourceId string `position:"Query" name:"ResourceId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
Tag *[]AddTagsTag `position:"Query" name:"Tag" type:"Repeated"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
ResourceType string `position:"Query" name:"ResourceType"`
}
@@ -101,7 +96,8 @@ func CreateAddTagsRequest() (request *AddTagsRequest) {
request = &AddTagsRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AddTags", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AddTags", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AllocateDedicatedHosts invokes the ecs.AllocateDedicatedHosts API synchronously
// api document: https://help.aliyun.com/api/ecs/allocatededicatedhosts.html
func (client *Client) AllocateDedicatedHosts(request *AllocateDedicatedHostsRequest) (response *AllocateDedicatedHostsResponse, err error) {
response = CreateAllocateDedicatedHostsResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AllocateDedicatedHosts(request *AllocateDedicatedHostsRequ
}
// AllocateDedicatedHostsWithChan invokes the ecs.AllocateDedicatedHosts API asynchronously
// api document: https://help.aliyun.com/api/ecs/allocatededicatedhosts.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AllocateDedicatedHostsWithChan(request *AllocateDedicatedHostsRequest) (<-chan *AllocateDedicatedHostsResponse, <-chan error) {
responseChan := make(chan *AllocateDedicatedHostsResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AllocateDedicatedHostsWithChan(request *AllocateDedicatedH
}
// AllocateDedicatedHostsWithCallback invokes the ecs.AllocateDedicatedHosts API asynchronously
// api document: https://help.aliyun.com/api/ecs/allocatededicatedhosts.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AllocateDedicatedHostsWithCallback(request *AllocateDedicatedHostsRequest, callback func(response *AllocateDedicatedHostsResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -79,8 +74,10 @@ type AllocateDedicatedHostsRequest struct {
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ClientToken string `position:"Query" name:"ClientToken"`
Description string `position:"Query" name:"Description"`
CpuOverCommitRatio requests.Float `position:"Query" name:"CpuOverCommitRatio"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
ActionOnMaintenance string `position:"Query" name:"ActionOnMaintenance"`
DedicatedHostClusterId string `position:"Query" name:"DedicatedHostClusterId"`
Tag *[]AllocateDedicatedHostsTag `position:"Query" name:"Tag" type:"Repeated"`
DedicatedHostType string `position:"Query" name:"DedicatedHostType"`
AutoRenewPeriod requests.Integer `position:"Query" name:"AutoRenewPeriod"`
@@ -95,6 +92,7 @@ type AllocateDedicatedHostsRequest struct {
AutoRenew requests.Boolean `position:"Query" name:"AutoRenew"`
NetworkAttributesSlbUdpTimeout requests.Integer `position:"Query" name:"NetworkAttributes.SlbUdpTimeout"`
ZoneId string `position:"Query" name:"ZoneId"`
AutoPlacement string `position:"Query" name:"AutoPlacement"`
ChargeType string `position:"Query" name:"ChargeType"`
NetworkAttributesUdpTimeout requests.Integer `position:"Query" name:"NetworkAttributes.UdpTimeout"`
}
@@ -117,7 +115,8 @@ func CreateAllocateDedicatedHostsRequest() (request *AllocateDedicatedHostsReque
request = &AllocateDedicatedHostsRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AllocateDedicatedHosts", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AllocateDedicatedHosts", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AllocateEipAddress invokes the ecs.AllocateEipAddress API synchronously
// api document: https://help.aliyun.com/api/ecs/allocateeipaddress.html
func (client *Client) AllocateEipAddress(request *AllocateEipAddressRequest) (response *AllocateEipAddressResponse, err error) {
response = CreateAllocateEipAddressResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AllocateEipAddress(request *AllocateEipAddressRequest) (re
}
// AllocateEipAddressWithChan invokes the ecs.AllocateEipAddress API asynchronously
// api document: https://help.aliyun.com/api/ecs/allocateeipaddress.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AllocateEipAddressWithChan(request *AllocateEipAddressRequest) (<-chan *AllocateEipAddressResponse, <-chan error) {
responseChan := make(chan *AllocateEipAddressResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AllocateEipAddressWithChan(request *AllocateEipAddressRequ
}
// AllocateEipAddressWithCallback invokes the ecs.AllocateEipAddress API asynchronously
// api document: https://help.aliyun.com/api/ecs/allocateeipaddress.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AllocateEipAddressWithCallback(request *AllocateEipAddressRequest, callback func(response *AllocateEipAddressResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,12 +72,14 @@ func (client *Client) AllocateEipAddressWithCallback(request *AllocateEipAddress
type AllocateEipAddressRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ClientToken string `position:"Query" name:"ClientToken"`
ISP string `position:"Query" name:"ISP"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
Bandwidth string `position:"Query" name:"Bandwidth"`
ClientToken string `position:"Query" name:"ClientToken"`
InternetChargeType string `position:"Query" name:"InternetChargeType"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
ActivityId requests.Integer `position:"Query" name:"ActivityId"`
InternetChargeType string `position:"Query" name:"InternetChargeType"`
}
// AllocateEipAddressResponse is the response struct for api AllocateEipAddress
@@ -98,7 +95,8 @@ func CreateAllocateEipAddressRequest() (request *AllocateEipAddressRequest) {
request = &AllocateEipAddressRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AllocateEipAddress", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AllocateEipAddress", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AllocatePublicIpAddress invokes the ecs.AllocatePublicIpAddress API synchronously
// api document: https://help.aliyun.com/api/ecs/allocatepublicipaddress.html
func (client *Client) AllocatePublicIpAddress(request *AllocatePublicIpAddressRequest) (response *AllocatePublicIpAddressResponse, err error) {
response = CreateAllocatePublicIpAddressResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AllocatePublicIpAddress(request *AllocatePublicIpAddressRe
}
// AllocatePublicIpAddressWithChan invokes the ecs.AllocatePublicIpAddress API asynchronously
// api document: https://help.aliyun.com/api/ecs/allocatepublicipaddress.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AllocatePublicIpAddressWithChan(request *AllocatePublicIpAddressRequest) (<-chan *AllocatePublicIpAddressResponse, <-chan error) {
responseChan := make(chan *AllocatePublicIpAddressResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AllocatePublicIpAddressWithChan(request *AllocatePublicIpA
}
// AllocatePublicIpAddressWithCallback invokes the ecs.AllocatePublicIpAddress API asynchronously
// api document: https://help.aliyun.com/api/ecs/allocatepublicipaddress.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AllocatePublicIpAddressWithCallback(request *AllocatePublicIpAddressRequest, callback func(response *AllocatePublicIpAddressResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -78,11 +73,11 @@ type AllocatePublicIpAddressRequest struct {
*requests.RpcRequest
IpAddress string `position:"Query" name:"IpAddress"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
VlanId string `position:"Query" name:"VlanId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
}
// AllocatePublicIpAddressResponse is the response struct for api AllocatePublicIpAddress
@@ -97,7 +92,8 @@ func CreateAllocatePublicIpAddressRequest() (request *AllocatePublicIpAddressReq
request = &AllocatePublicIpAddressRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AllocatePublicIpAddress", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AllocatePublicIpAddress", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// ApplyAutoSnapshotPolicy invokes the ecs.ApplyAutoSnapshotPolicy API synchronously
// api document: https://help.aliyun.com/api/ecs/applyautosnapshotpolicy.html
func (client *Client) ApplyAutoSnapshotPolicy(request *ApplyAutoSnapshotPolicyRequest) (response *ApplyAutoSnapshotPolicyResponse, err error) {
response = CreateApplyAutoSnapshotPolicyResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) ApplyAutoSnapshotPolicy(request *ApplyAutoSnapshotPolicyRe
}
// ApplyAutoSnapshotPolicyWithChan invokes the ecs.ApplyAutoSnapshotPolicy API asynchronously
// api document: https://help.aliyun.com/api/ecs/applyautosnapshotpolicy.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) ApplyAutoSnapshotPolicyWithChan(request *ApplyAutoSnapshotPolicyRequest) (<-chan *ApplyAutoSnapshotPolicyResponse, <-chan error) {
responseChan := make(chan *ApplyAutoSnapshotPolicyResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) ApplyAutoSnapshotPolicyWithChan(request *ApplyAutoSnapshot
}
// ApplyAutoSnapshotPolicyWithCallback invokes the ecs.ApplyAutoSnapshotPolicy API asynchronously
// api document: https://help.aliyun.com/api/ecs/applyautosnapshotpolicy.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) ApplyAutoSnapshotPolicyWithCallback(request *ApplyAutoSnapshotPolicyRequest, callback func(response *ApplyAutoSnapshotPolicyResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,9 +72,9 @@ func (client *Client) ApplyAutoSnapshotPolicyWithCallback(request *ApplyAutoSnap
type ApplyAutoSnapshotPolicyRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
AutoSnapshotPolicyId string `position:"Query" name:"autoSnapshotPolicyId"`
DiskIds string `position:"Query" name:"diskIds"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
}
@@ -94,7 +89,8 @@ func CreateApplyAutoSnapshotPolicyRequest() (request *ApplyAutoSnapshotPolicyReq
request = &ApplyAutoSnapshotPolicyRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "ApplyAutoSnapshotPolicy", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "ApplyAutoSnapshotPolicy", "", "")
request.Method = requests.POST
return
}

View File

@@ -0,0 +1,105 @@
package ecs
//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.
//
// Code generated by Alibaba Cloud SDK Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
)
// AssignIpv6Addresses invokes the ecs.AssignIpv6Addresses API synchronously
func (client *Client) AssignIpv6Addresses(request *AssignIpv6AddressesRequest) (response *AssignIpv6AddressesResponse, err error) {
response = CreateAssignIpv6AddressesResponse()
err = client.DoAction(request, response)
return
}
// AssignIpv6AddressesWithChan invokes the ecs.AssignIpv6Addresses API asynchronously
func (client *Client) AssignIpv6AddressesWithChan(request *AssignIpv6AddressesRequest) (<-chan *AssignIpv6AddressesResponse, <-chan error) {
responseChan := make(chan *AssignIpv6AddressesResponse, 1)
errChan := make(chan error, 1)
err := client.AddAsyncTask(func() {
defer close(responseChan)
defer close(errChan)
response, err := client.AssignIpv6Addresses(request)
if err != nil {
errChan <- err
} else {
responseChan <- response
}
})
if err != nil {
errChan <- err
close(responseChan)
close(errChan)
}
return responseChan, errChan
}
// AssignIpv6AddressesWithCallback invokes the ecs.AssignIpv6Addresses API asynchronously
func (client *Client) AssignIpv6AddressesWithCallback(request *AssignIpv6AddressesRequest, callback func(response *AssignIpv6AddressesResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
var response *AssignIpv6AddressesResponse
var err error
defer close(result)
response, err = client.AssignIpv6Addresses(request)
callback(response, err)
result <- 1
})
if err != nil {
defer close(result)
callback(nil, err)
result <- 0
}
return result
}
// AssignIpv6AddressesRequest is the request struct for api AssignIpv6Addresses
type AssignIpv6AddressesRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
Ipv6AddressCount requests.Integer `position:"Query" name:"Ipv6AddressCount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
NetworkInterfaceId string `position:"Query" name:"NetworkInterfaceId"`
Ipv6Address *[]string `position:"Query" name:"Ipv6Address" type:"Repeated"`
}
// AssignIpv6AddressesResponse is the response struct for api AssignIpv6Addresses
type AssignIpv6AddressesResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
}
// CreateAssignIpv6AddressesRequest creates a request to invoke AssignIpv6Addresses API
func CreateAssignIpv6AddressesRequest() (request *AssignIpv6AddressesRequest) {
request = &AssignIpv6AddressesRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AssignIpv6Addresses", "", "")
request.Method = requests.POST
return
}
// CreateAssignIpv6AddressesResponse creates a response to parse from AssignIpv6Addresses response
func CreateAssignIpv6AddressesResponse() (response *AssignIpv6AddressesResponse) {
response = &AssignIpv6AddressesResponse{
BaseResponse: &responses.BaseResponse{},
}
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AssignPrivateIpAddresses invokes the ecs.AssignPrivateIpAddresses API synchronously
// api document: https://help.aliyun.com/api/ecs/assignprivateipaddresses.html
func (client *Client) AssignPrivateIpAddresses(request *AssignPrivateIpAddressesRequest) (response *AssignPrivateIpAddressesResponse, err error) {
response = CreateAssignPrivateIpAddressesResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AssignPrivateIpAddresses(request *AssignPrivateIpAddresses
}
// AssignPrivateIpAddressesWithChan invokes the ecs.AssignPrivateIpAddresses API asynchronously
// api document: https://help.aliyun.com/api/ecs/assignprivateipaddresses.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AssignPrivateIpAddressesWithChan(request *AssignPrivateIpAddressesRequest) (<-chan *AssignPrivateIpAddressesResponse, <-chan error) {
responseChan := make(chan *AssignPrivateIpAddressesResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AssignPrivateIpAddressesWithChan(request *AssignPrivateIpA
}
// AssignPrivateIpAddressesWithCallback invokes the ecs.AssignPrivateIpAddresses API asynchronously
// api document: https://help.aliyun.com/api/ecs/assignprivateipaddresses.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AssignPrivateIpAddressesWithCallback(request *AssignPrivateIpAddressesRequest, callback func(response *AssignPrivateIpAddressesResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,6 +72,7 @@ func (client *Client) AssignPrivateIpAddressesWithCallback(request *AssignPrivat
type AssignPrivateIpAddressesRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ClientToken string `position:"Query" name:"ClientToken"`
SecondaryPrivateIpAddressCount requests.Integer `position:"Query" name:"SecondaryPrivateIpAddressCount"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
@@ -88,7 +84,8 @@ type AssignPrivateIpAddressesRequest struct {
// AssignPrivateIpAddressesResponse is the response struct for api AssignPrivateIpAddresses
type AssignPrivateIpAddressesResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
RequestId string `json:"RequestId" xml:"RequestId"`
AssignedPrivateIpAddressesSet AssignedPrivateIpAddressesSet `json:"AssignedPrivateIpAddressesSet" xml:"AssignedPrivateIpAddressesSet"`
}
// CreateAssignPrivateIpAddressesRequest creates a request to invoke AssignPrivateIpAddresses API
@@ -96,7 +93,8 @@ func CreateAssignPrivateIpAddressesRequest() (request *AssignPrivateIpAddressesR
request = &AssignPrivateIpAddressesRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AssignPrivateIpAddresses", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AssignPrivateIpAddresses", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AssociateEipAddress invokes the ecs.AssociateEipAddress API synchronously
// api document: https://help.aliyun.com/api/ecs/associateeipaddress.html
func (client *Client) AssociateEipAddress(request *AssociateEipAddressRequest) (response *AssociateEipAddressResponse, err error) {
response = CreateAssociateEipAddressResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AssociateEipAddress(request *AssociateEipAddressRequest) (
}
// AssociateEipAddressWithChan invokes the ecs.AssociateEipAddress API asynchronously
// api document: https://help.aliyun.com/api/ecs/associateeipaddress.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AssociateEipAddressWithChan(request *AssociateEipAddressRequest) (<-chan *AssociateEipAddressResponse, <-chan error) {
responseChan := make(chan *AssociateEipAddressResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AssociateEipAddressWithChan(request *AssociateEipAddressRe
}
// AssociateEipAddressWithCallback invokes the ecs.AssociateEipAddress API asynchronously
// api document: https://help.aliyun.com/api/ecs/associateeipaddress.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AssociateEipAddressWithCallback(request *AssociateEipAddressRequest, callback func(response *AssociateEipAddressResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,12 +72,12 @@ func (client *Client) AssociateEipAddressWithCallback(request *AssociateEipAddre
type AssociateEipAddressRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
AllocationId string `position:"Query" name:"AllocationId"`
InstanceType string `position:"Query" name:"InstanceType"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
InstanceType string `position:"Query" name:"InstanceType"`
AllocationId string `position:"Query" name:"AllocationId"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
}
// AssociateEipAddressResponse is the response struct for api AssociateEipAddress
@@ -96,7 +91,8 @@ func CreateAssociateEipAddressRequest() (request *AssociateEipAddressRequest) {
request = &AssociateEipAddressRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AssociateEipAddress", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AssociateEipAddress", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AssociateHaVip invokes the ecs.AssociateHaVip API synchronously
// api document: https://help.aliyun.com/api/ecs/associatehavip.html
func (client *Client) AssociateHaVip(request *AssociateHaVipRequest) (response *AssociateHaVipResponse, err error) {
response = CreateAssociateHaVipResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AssociateHaVip(request *AssociateHaVipRequest) (response *
}
// AssociateHaVipWithChan invokes the ecs.AssociateHaVip API asynchronously
// api document: https://help.aliyun.com/api/ecs/associatehavip.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AssociateHaVipWithChan(request *AssociateHaVipRequest) (<-chan *AssociateHaVipResponse, <-chan error) {
responseChan := make(chan *AssociateHaVipResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AssociateHaVipWithChan(request *AssociateHaVipRequest) (<-
}
// AssociateHaVipWithCallback invokes the ecs.AssociateHaVip API asynchronously
// api document: https://help.aliyun.com/api/ecs/associatehavip.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AssociateHaVipWithCallback(request *AssociateHaVipRequest, callback func(response *AssociateHaVipResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -76,13 +71,13 @@ func (client *Client) AssociateHaVipWithCallback(request *AssociateHaVipRequest,
// AssociateHaVipRequest is the request struct for api AssociateHaVip
type AssociateHaVipRequest struct {
*requests.RpcRequest
HaVipId string `position:"Query" name:"HaVipId"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
ClientToken string `position:"Query" name:"ClientToken"`
HaVipId string `position:"Query" name:"HaVipId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
}
// AssociateHaVipResponse is the response struct for api AssociateHaVip
@@ -96,7 +91,8 @@ func CreateAssociateHaVipRequest() (request *AssociateHaVipRequest) {
request = &AssociateHaVipRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AssociateHaVip", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AssociateHaVip", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AttachClassicLinkVpc invokes the ecs.AttachClassicLinkVpc API synchronously
// api document: https://help.aliyun.com/api/ecs/attachclassiclinkvpc.html
func (client *Client) AttachClassicLinkVpc(request *AttachClassicLinkVpcRequest) (response *AttachClassicLinkVpcResponse, err error) {
response = CreateAttachClassicLinkVpcResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AttachClassicLinkVpc(request *AttachClassicLinkVpcRequest)
}
// AttachClassicLinkVpcWithChan invokes the ecs.AttachClassicLinkVpc API asynchronously
// api document: https://help.aliyun.com/api/ecs/attachclassiclinkvpc.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AttachClassicLinkVpcWithChan(request *AttachClassicLinkVpcRequest) (<-chan *AttachClassicLinkVpcResponse, <-chan error) {
responseChan := make(chan *AttachClassicLinkVpcResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AttachClassicLinkVpcWithChan(request *AttachClassicLinkVpc
}
// AttachClassicLinkVpcWithCallback invokes the ecs.AttachClassicLinkVpc API asynchronously
// api document: https://help.aliyun.com/api/ecs/attachclassiclinkvpc.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AttachClassicLinkVpcWithCallback(request *AttachClassicLinkVpcRequest, callback func(response *AttachClassicLinkVpcResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,10 +72,10 @@ func (client *Client) AttachClassicLinkVpcWithCallback(request *AttachClassicLin
type AttachClassicLinkVpcRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
VpcId string `position:"Query" name:"VpcId"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
VpcId string `position:"Query" name:"VpcId"`
}
// AttachClassicLinkVpcResponse is the response struct for api AttachClassicLinkVpc
@@ -94,7 +89,8 @@ func CreateAttachClassicLinkVpcRequest() (request *AttachClassicLinkVpcRequest)
request = &AttachClassicLinkVpcRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AttachClassicLinkVpc", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AttachClassicLinkVpc", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AttachDisk invokes the ecs.AttachDisk API synchronously
// api document: https://help.aliyun.com/api/ecs/attachdisk.html
func (client *Client) AttachDisk(request *AttachDiskRequest) (response *AttachDiskResponse, err error) {
response = CreateAttachDiskResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AttachDisk(request *AttachDiskRequest) (response *AttachDi
}
// AttachDiskWithChan invokes the ecs.AttachDisk API asynchronously
// api document: https://help.aliyun.com/api/ecs/attachdisk.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AttachDiskWithChan(request *AttachDiskRequest) (<-chan *AttachDiskResponse, <-chan error) {
responseChan := make(chan *AttachDiskResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AttachDiskWithChan(request *AttachDiskRequest) (<-chan *At
}
// AttachDiskWithCallback invokes the ecs.AttachDisk API asynchronously
// api document: https://help.aliyun.com/api/ecs/attachdisk.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AttachDiskWithCallback(request *AttachDiskRequest, callback func(response *AttachDiskResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,13 +72,16 @@ func (client *Client) AttachDiskWithCallback(request *AttachDiskRequest, callbac
type AttachDiskRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
KeyPairName string `position:"Query" name:"KeyPairName"`
Bootable requests.Boolean `position:"Query" name:"Bootable"`
Password string `position:"Query" name:"Password"`
DiskId string `position:"Query" name:"DiskId"`
DeleteWithInstance requests.Boolean `position:"Query" name:"DeleteWithInstance"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
DiskId string `position:"Query" name:"DiskId"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
Device string `position:"Query" name:"Device"`
DeleteWithInstance requests.Boolean `position:"Query" name:"DeleteWithInstance"`
}
// AttachDiskResponse is the response struct for api AttachDisk
@@ -97,7 +95,8 @@ func CreateAttachDiskRequest() (request *AttachDiskRequest) {
request = &AttachDiskRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AttachDisk", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AttachDisk", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AttachInstanceRamRole invokes the ecs.AttachInstanceRamRole API synchronously
// api document: https://help.aliyun.com/api/ecs/attachinstanceramrole.html
func (client *Client) AttachInstanceRamRole(request *AttachInstanceRamRoleRequest) (response *AttachInstanceRamRoleResponse, err error) {
response = CreateAttachInstanceRamRoleResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AttachInstanceRamRole(request *AttachInstanceRamRoleReques
}
// AttachInstanceRamRoleWithChan invokes the ecs.AttachInstanceRamRole API asynchronously
// api document: https://help.aliyun.com/api/ecs/attachinstanceramrole.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AttachInstanceRamRoleWithChan(request *AttachInstanceRamRoleRequest) (<-chan *AttachInstanceRamRoleResponse, <-chan error) {
responseChan := make(chan *AttachInstanceRamRoleResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AttachInstanceRamRoleWithChan(request *AttachInstanceRamRo
}
// AttachInstanceRamRoleWithCallback invokes the ecs.AttachInstanceRamRole API asynchronously
// api document: https://help.aliyun.com/api/ecs/attachinstanceramrole.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AttachInstanceRamRoleWithCallback(request *AttachInstanceRamRoleRequest, callback func(response *AttachInstanceRamRoleResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -78,9 +73,9 @@ type AttachInstanceRamRoleRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
InstanceIds string `position:"Query" name:"InstanceIds"`
RamRoleName string `position:"Query" name:"RamRoleName"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
InstanceIds string `position:"Query" name:"InstanceIds"`
}
// AttachInstanceRamRoleResponse is the response struct for api AttachInstanceRamRole
@@ -98,7 +93,8 @@ func CreateAttachInstanceRamRoleRequest() (request *AttachInstanceRamRoleRequest
request = &AttachInstanceRamRoleRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AttachInstanceRamRole", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AttachInstanceRamRole", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AttachKeyPair invokes the ecs.AttachKeyPair API synchronously
// api document: https://help.aliyun.com/api/ecs/attachkeypair.html
func (client *Client) AttachKeyPair(request *AttachKeyPairRequest) (response *AttachKeyPairResponse, err error) {
response = CreateAttachKeyPairResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AttachKeyPair(request *AttachKeyPairRequest) (response *At
}
// AttachKeyPairWithChan invokes the ecs.AttachKeyPair API asynchronously
// api document: https://help.aliyun.com/api/ecs/attachkeypair.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AttachKeyPairWithChan(request *AttachKeyPairRequest) (<-chan *AttachKeyPairResponse, <-chan error) {
responseChan := make(chan *AttachKeyPairResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AttachKeyPairWithChan(request *AttachKeyPairRequest) (<-ch
}
// AttachKeyPairWithCallback invokes the ecs.AttachKeyPair API asynchronously
// api document: https://help.aliyun.com/api/ecs/attachkeypair.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AttachKeyPairWithCallback(request *AttachKeyPairRequest, callback func(response *AttachKeyPairResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,10 +72,10 @@ func (client *Client) AttachKeyPairWithCallback(request *AttachKeyPairRequest, c
type AttachKeyPairRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
InstanceIds string `position:"Query" name:"InstanceIds"`
KeyPairName string `position:"Query" name:"KeyPairName"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
InstanceIds string `position:"Query" name:"InstanceIds"`
}
// AttachKeyPairResponse is the response struct for api AttachKeyPair
@@ -98,7 +93,8 @@ func CreateAttachKeyPairRequest() (request *AttachKeyPairRequest) {
request = &AttachKeyPairRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AttachKeyPair", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AttachKeyPair", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AttachNetworkInterface invokes the ecs.AttachNetworkInterface API synchronously
// api document: https://help.aliyun.com/api/ecs/attachnetworkinterface.html
func (client *Client) AttachNetworkInterface(request *AttachNetworkInterfaceRequest) (response *AttachNetworkInterfaceResponse, err error) {
response = CreateAttachNetworkInterfaceResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AttachNetworkInterface(request *AttachNetworkInterfaceRequ
}
// AttachNetworkInterfaceWithChan invokes the ecs.AttachNetworkInterface API asynchronously
// api document: https://help.aliyun.com/api/ecs/attachnetworkinterface.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AttachNetworkInterfaceWithChan(request *AttachNetworkInterfaceRequest) (<-chan *AttachNetworkInterfaceResponse, <-chan error) {
responseChan := make(chan *AttachNetworkInterfaceResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AttachNetworkInterfaceWithChan(request *AttachNetworkInter
}
// AttachNetworkInterfaceWithCallback invokes the ecs.AttachNetworkInterface API asynchronously
// api document: https://help.aliyun.com/api/ecs/attachnetworkinterface.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AttachNetworkInterfaceWithCallback(request *AttachNetworkInterfaceRequest, callback func(response *AttachNetworkInterfaceResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -76,12 +71,14 @@ func (client *Client) AttachNetworkInterfaceWithCallback(request *AttachNetworkI
// AttachNetworkInterfaceRequest is the request struct for api AttachNetworkInterface
type AttachNetworkInterfaceRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
NetworkInterfaceId string `position:"Query" name:"NetworkInterfaceId"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
TrunkNetworkInstanceId string `position:"Query" name:"TrunkNetworkInstanceId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
WaitForNetworkConfigurationReady requests.Boolean `position:"Query" name:"WaitForNetworkConfigurationReady"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
NetworkInterfaceId string `position:"Query" name:"NetworkInterfaceId"`
}
// AttachNetworkInterfaceResponse is the response struct for api AttachNetworkInterface
@@ -95,7 +92,8 @@ func CreateAttachNetworkInterfaceRequest() (request *AttachNetworkInterfaceReque
request = &AttachNetworkInterfaceRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AttachNetworkInterface", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AttachNetworkInterface", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AuthorizeSecurityGroup invokes the ecs.AuthorizeSecurityGroup API synchronously
// api document: https://help.aliyun.com/api/ecs/authorizesecuritygroup.html
func (client *Client) AuthorizeSecurityGroup(request *AuthorizeSecurityGroupRequest) (response *AuthorizeSecurityGroupResponse, err error) {
response = CreateAuthorizeSecurityGroupResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AuthorizeSecurityGroup(request *AuthorizeSecurityGroupRequ
}
// AuthorizeSecurityGroupWithChan invokes the ecs.AuthorizeSecurityGroup API asynchronously
// api document: https://help.aliyun.com/api/ecs/authorizesecuritygroup.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AuthorizeSecurityGroupWithChan(request *AuthorizeSecurityGroupRequest) (<-chan *AuthorizeSecurityGroupResponse, <-chan error) {
responseChan := make(chan *AuthorizeSecurityGroupResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AuthorizeSecurityGroupWithChan(request *AuthorizeSecurityG
}
// AuthorizeSecurityGroupWithCallback invokes the ecs.AuthorizeSecurityGroup API asynchronously
// api document: https://help.aliyun.com/api/ecs/authorizesecuritygroup.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AuthorizeSecurityGroupWithCallback(request *AuthorizeSecurityGroupRequest, callback func(response *AuthorizeSecurityGroupResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -84,6 +79,8 @@ type AuthorizeSecurityGroupRequest struct {
Description string `position:"Query" name:"Description"`
SourceGroupOwnerId requests.Integer `position:"Query" name:"SourceGroupOwnerId"`
SourceGroupOwnerAccount string `position:"Query" name:"SourceGroupOwnerAccount"`
Ipv6SourceCidrIp string `position:"Query" name:"Ipv6SourceCidrIp"`
Ipv6DestCidrIp string `position:"Query" name:"Ipv6DestCidrIp"`
Policy string `position:"Query" name:"Policy"`
PortRange string `position:"Query" name:"PortRange"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
@@ -107,7 +104,8 @@ func CreateAuthorizeSecurityGroupRequest() (request *AuthorizeSecurityGroupReque
request = &AuthorizeSecurityGroupRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AuthorizeSecurityGroup", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AuthorizeSecurityGroup", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// AuthorizeSecurityGroupEgress invokes the ecs.AuthorizeSecurityGroupEgress API synchronously
// api document: https://help.aliyun.com/api/ecs/authorizesecuritygroupegress.html
func (client *Client) AuthorizeSecurityGroupEgress(request *AuthorizeSecurityGroupEgressRequest) (response *AuthorizeSecurityGroupEgressResponse, err error) {
response = CreateAuthorizeSecurityGroupEgressResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) AuthorizeSecurityGroupEgress(request *AuthorizeSecurityGro
}
// AuthorizeSecurityGroupEgressWithChan invokes the ecs.AuthorizeSecurityGroupEgress API asynchronously
// api document: https://help.aliyun.com/api/ecs/authorizesecuritygroupegress.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AuthorizeSecurityGroupEgressWithChan(request *AuthorizeSecurityGroupEgressRequest) (<-chan *AuthorizeSecurityGroupEgressResponse, <-chan error) {
responseChan := make(chan *AuthorizeSecurityGroupEgressResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) AuthorizeSecurityGroupEgressWithChan(request *AuthorizeSec
}
// AuthorizeSecurityGroupEgressWithCallback invokes the ecs.AuthorizeSecurityGroupEgress API asynchronously
// api document: https://help.aliyun.com/api/ecs/authorizesecuritygroupegress.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) AuthorizeSecurityGroupEgressWithCallback(request *AuthorizeSecurityGroupEgressRequest, callback func(response *AuthorizeSecurityGroupEgressResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -82,6 +77,8 @@ type AuthorizeSecurityGroupEgressRequest struct {
ClientToken string `position:"Query" name:"ClientToken"`
SecurityGroupId string `position:"Query" name:"SecurityGroupId"`
Description string `position:"Query" name:"Description"`
Ipv6DestCidrIp string `position:"Query" name:"Ipv6DestCidrIp"`
Ipv6SourceCidrIp string `position:"Query" name:"Ipv6SourceCidrIp"`
Policy string `position:"Query" name:"Policy"`
PortRange string `position:"Query" name:"PortRange"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
@@ -107,7 +104,8 @@ func CreateAuthorizeSecurityGroupEgressRequest() (request *AuthorizeSecurityGrou
request = &AuthorizeSecurityGroupEgressRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "AuthorizeSecurityGroupEgress", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "AuthorizeSecurityGroupEgress", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CancelAutoSnapshotPolicy invokes the ecs.CancelAutoSnapshotPolicy API synchronously
// api document: https://help.aliyun.com/api/ecs/cancelautosnapshotpolicy.html
func (client *Client) CancelAutoSnapshotPolicy(request *CancelAutoSnapshotPolicyRequest) (response *CancelAutoSnapshotPolicyResponse, err error) {
response = CreateCancelAutoSnapshotPolicyResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CancelAutoSnapshotPolicy(request *CancelAutoSnapshotPolicy
}
// CancelAutoSnapshotPolicyWithChan invokes the ecs.CancelAutoSnapshotPolicy API asynchronously
// api document: https://help.aliyun.com/api/ecs/cancelautosnapshotpolicy.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CancelAutoSnapshotPolicyWithChan(request *CancelAutoSnapshotPolicyRequest) (<-chan *CancelAutoSnapshotPolicyResponse, <-chan error) {
responseChan := make(chan *CancelAutoSnapshotPolicyResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CancelAutoSnapshotPolicyWithChan(request *CancelAutoSnapsh
}
// CancelAutoSnapshotPolicyWithCallback invokes the ecs.CancelAutoSnapshotPolicy API asynchronously
// api document: https://help.aliyun.com/api/ecs/cancelautosnapshotpolicy.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CancelAutoSnapshotPolicyWithCallback(request *CancelAutoSnapshotPolicyRequest, callback func(response *CancelAutoSnapshotPolicyResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,8 +72,8 @@ func (client *Client) CancelAutoSnapshotPolicyWithCallback(request *CancelAutoSn
type CancelAutoSnapshotPolicyRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
DiskIds string `position:"Query" name:"diskIds"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
}
@@ -93,7 +88,8 @@ func CreateCancelAutoSnapshotPolicyRequest() (request *CancelAutoSnapshotPolicyR
request = &CancelAutoSnapshotPolicyRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CancelAutoSnapshotPolicy", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CancelAutoSnapshotPolicy", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CancelCopyImage invokes the ecs.CancelCopyImage API synchronously
// api document: https://help.aliyun.com/api/ecs/cancelcopyimage.html
func (client *Client) CancelCopyImage(request *CancelCopyImageRequest) (response *CancelCopyImageResponse, err error) {
response = CreateCancelCopyImageResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CancelCopyImage(request *CancelCopyImageRequest) (response
}
// CancelCopyImageWithChan invokes the ecs.CancelCopyImage API asynchronously
// api document: https://help.aliyun.com/api/ecs/cancelcopyimage.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CancelCopyImageWithChan(request *CancelCopyImageRequest) (<-chan *CancelCopyImageResponse, <-chan error) {
responseChan := make(chan *CancelCopyImageResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CancelCopyImageWithChan(request *CancelCopyImageRequest) (
}
// CancelCopyImageWithCallback invokes the ecs.CancelCopyImage API asynchronously
// api document: https://help.aliyun.com/api/ecs/cancelcopyimage.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CancelCopyImageWithCallback(request *CancelCopyImageRequest, callback func(response *CancelCopyImageResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -94,7 +89,8 @@ func CreateCancelCopyImageRequest() (request *CancelCopyImageRequest) {
request = &CancelCopyImageRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CancelCopyImage", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CancelCopyImage", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CancelPhysicalConnection invokes the ecs.CancelPhysicalConnection API synchronously
// api document: https://help.aliyun.com/api/ecs/cancelphysicalconnection.html
func (client *Client) CancelPhysicalConnection(request *CancelPhysicalConnectionRequest) (response *CancelPhysicalConnectionResponse, err error) {
response = CreateCancelPhysicalConnectionResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CancelPhysicalConnection(request *CancelPhysicalConnection
}
// CancelPhysicalConnectionWithChan invokes the ecs.CancelPhysicalConnection API asynchronously
// api document: https://help.aliyun.com/api/ecs/cancelphysicalconnection.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CancelPhysicalConnectionWithChan(request *CancelPhysicalConnectionRequest) (<-chan *CancelPhysicalConnectionResponse, <-chan error) {
responseChan := make(chan *CancelPhysicalConnectionResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CancelPhysicalConnectionWithChan(request *CancelPhysicalCo
}
// CancelPhysicalConnectionWithCallback invokes the ecs.CancelPhysicalConnection API asynchronously
// api document: https://help.aliyun.com/api/ecs/cancelphysicalconnection.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CancelPhysicalConnectionWithCallback(request *CancelPhysicalConnectionRequest, callback func(response *CancelPhysicalConnectionResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,12 +72,12 @@ func (client *Client) CancelPhysicalConnectionWithCallback(request *CancelPhysic
type CancelPhysicalConnectionRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
ClientToken string `position:"Query" name:"ClientToken"`
PhysicalConnectionId string `position:"Query" name:"PhysicalConnectionId"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
UserCidr string `position:"Query" name:"UserCidr"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
PhysicalConnectionId string `position:"Query" name:"PhysicalConnectionId"`
}
// CancelPhysicalConnectionResponse is the response struct for api CancelPhysicalConnection
@@ -96,7 +91,8 @@ func CreateCancelPhysicalConnectionRequest() (request *CancelPhysicalConnectionR
request = &CancelPhysicalConnectionRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CancelPhysicalConnection", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CancelPhysicalConnection", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CancelSimulatedSystemEvents invokes the ecs.CancelSimulatedSystemEvents API synchronously
// api document: https://help.aliyun.com/api/ecs/cancelsimulatedsystemevents.html
func (client *Client) CancelSimulatedSystemEvents(request *CancelSimulatedSystemEventsRequest) (response *CancelSimulatedSystemEventsResponse, err error) {
response = CreateCancelSimulatedSystemEventsResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CancelSimulatedSystemEvents(request *CancelSimulatedSystem
}
// CancelSimulatedSystemEventsWithChan invokes the ecs.CancelSimulatedSystemEvents API asynchronously
// api document: https://help.aliyun.com/api/ecs/cancelsimulatedsystemevents.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CancelSimulatedSystemEventsWithChan(request *CancelSimulatedSystemEventsRequest) (<-chan *CancelSimulatedSystemEventsResponse, <-chan error) {
responseChan := make(chan *CancelSimulatedSystemEventsResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CancelSimulatedSystemEventsWithChan(request *CancelSimulat
}
// CancelSimulatedSystemEventsWithCallback invokes the ecs.CancelSimulatedSystemEvents API asynchronously
// api document: https://help.aliyun.com/api/ecs/cancelsimulatedsystemevents.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CancelSimulatedSystemEventsWithCallback(request *CancelSimulatedSystemEventsRequest, callback func(response *CancelSimulatedSystemEventsResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -94,7 +89,8 @@ func CreateCancelSimulatedSystemEventsRequest() (request *CancelSimulatedSystemE
request = &CancelSimulatedSystemEventsRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CancelSimulatedSystemEvents", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CancelSimulatedSystemEvents", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CancelTask invokes the ecs.CancelTask API synchronously
// api document: https://help.aliyun.com/api/ecs/canceltask.html
func (client *Client) CancelTask(request *CancelTaskRequest) (response *CancelTaskResponse, err error) {
response = CreateCancelTaskResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CancelTask(request *CancelTaskRequest) (response *CancelTa
}
// CancelTaskWithChan invokes the ecs.CancelTask API asynchronously
// api document: https://help.aliyun.com/api/ecs/canceltask.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CancelTaskWithChan(request *CancelTaskRequest) (<-chan *CancelTaskResponse, <-chan error) {
responseChan := make(chan *CancelTaskResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CancelTaskWithChan(request *CancelTaskRequest) (<-chan *Ca
}
// CancelTaskWithCallback invokes the ecs.CancelTask API asynchronously
// api document: https://help.aliyun.com/api/ecs/canceltask.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CancelTaskWithCallback(request *CancelTaskRequest, callback func(response *CancelTaskResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,9 +72,9 @@ func (client *Client) CancelTaskWithCallback(request *CancelTaskRequest, callbac
type CancelTaskRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
TaskId string `position:"Query" name:"TaskId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
TaskId string `position:"Query" name:"TaskId"`
}
// CancelTaskResponse is the response struct for api CancelTask
@@ -93,7 +88,8 @@ func CreateCancelTaskRequest() (request *CancelTaskRequest) {
request = &CancelTaskRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CancelTask", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CancelTask", "", "")
request.Method = requests.POST
return
}

View File

@@ -16,8 +16,11 @@ package ecs
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"reflect"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider"
)
// Client is the sdk client struct, each func corresponds to an OpenAPI
@@ -25,10 +28,40 @@ type Client struct {
sdk.Client
}
// SetClientProperty Set Property by Reflect
func SetClientProperty(client *Client, propertyName string, propertyValue interface{}) {
v := reflect.ValueOf(client).Elem()
if v.FieldByName(propertyName).IsValid() && v.FieldByName(propertyName).CanSet() {
v.FieldByName(propertyName).Set(reflect.ValueOf(propertyValue))
}
}
// SetEndpointDataToClient Set EndpointMap and ENdpointType
func SetEndpointDataToClient(client *Client) {
SetClientProperty(client, "EndpointMap", GetEndpointMap())
SetClientProperty(client, "EndpointType", GetEndpointType())
}
// NewClient creates a sdk client with environment variables
func NewClient() (client *Client, err error) {
client = &Client{}
err = client.Init()
SetEndpointDataToClient(client)
return
}
// NewClientWithProvider creates a sdk client with providers
// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
func NewClientWithProvider(regionId string, providers ...provider.Provider) (client *Client, err error) {
client = &Client{}
var pc provider.Provider
if len(providers) == 0 {
pc = provider.DefaultChain
} else {
pc = provider.NewProviderChain(providers)
}
err = client.InitWithProviderChain(regionId, pc)
SetEndpointDataToClient(client)
return
}
@@ -37,45 +70,60 @@ func NewClient() (client *Client, err error) {
func NewClientWithOptions(regionId string, config *sdk.Config, credential auth.Credential) (client *Client, err error) {
client = &Client{}
err = client.InitWithOptions(regionId, config, credential)
SetEndpointDataToClient(client)
return
}
// NewClientWithAccessKey is a shortcut to create sdk client with accesskey
// usage: https://help.aliyun.com/document_detail/66217.html
// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (client *Client, err error) {
client = &Client{}
err = client.InitWithAccessKey(regionId, accessKeyId, accessKeySecret)
SetEndpointDataToClient(client)
return
}
// NewClientWithStsToken is a shortcut to create sdk client with sts token
// usage: https://help.aliyun.com/document_detail/66222.html
// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken string) (client *Client, err error) {
client = &Client{}
err = client.InitWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken)
SetEndpointDataToClient(client)
return
}
// NewClientWithRamRoleArn is a shortcut to create sdk client with ram roleArn
// usage: https://help.aliyun.com/document_detail/66222.html
// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
func NewClientWithRamRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) {
client = &Client{}
err = client.InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName)
SetEndpointDataToClient(client)
return
}
// NewClientWithRamRoleArn is a shortcut to create sdk client with ram roleArn and policy
// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
func NewClientWithRamRoleArnAndPolicy(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string) (client *Client, err error) {
client = &Client{}
err = client.InitWithRamRoleArnAndPolicy(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy)
SetEndpointDataToClient(client)
return
}
// NewClientWithEcsRamRole is a shortcut to create sdk client with ecs ram role
// usage: https://help.aliyun.com/document_detail/66223.html
// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client, err error) {
client = &Client{}
err = client.InitWithEcsRamRole(regionId, roleName)
SetEndpointDataToClient(client)
return
}
// NewClientWithRsaKeyPair is a shortcut to create sdk client with rsa key pair
// attention: rsa key pair auth is only Japan regions available
// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
func NewClientWithRsaKeyPair(regionId string, publicKeyId, privateKey string, sessionExpiration int) (client *Client, err error) {
client = &Client{}
err = client.InitWithRsaKeyPair(regionId, publicKeyId, privateKey, sessionExpiration)
SetEndpointDataToClient(client)
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// ConnectRouterInterface invokes the ecs.ConnectRouterInterface API synchronously
// api document: https://help.aliyun.com/api/ecs/connectrouterinterface.html
func (client *Client) ConnectRouterInterface(request *ConnectRouterInterfaceRequest) (response *ConnectRouterInterfaceResponse, err error) {
response = CreateConnectRouterInterfaceResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) ConnectRouterInterface(request *ConnectRouterInterfaceRequ
}
// ConnectRouterInterfaceWithChan invokes the ecs.ConnectRouterInterface API asynchronously
// api document: https://help.aliyun.com/api/ecs/connectrouterinterface.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) ConnectRouterInterfaceWithChan(request *ConnectRouterInterfaceRequest) (<-chan *ConnectRouterInterfaceResponse, <-chan error) {
responseChan := make(chan *ConnectRouterInterfaceResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) ConnectRouterInterfaceWithChan(request *ConnectRouterInter
}
// ConnectRouterInterfaceWithCallback invokes the ecs.ConnectRouterInterface API asynchronously
// api document: https://help.aliyun.com/api/ecs/connectrouterinterface.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) ConnectRouterInterfaceWithCallback(request *ConnectRouterInterfaceRequest, callback func(response *ConnectRouterInterfaceResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -93,7 +88,8 @@ func CreateConnectRouterInterfaceRequest() (request *ConnectRouterInterfaceReque
request = &ConnectRouterInterfaceRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "ConnectRouterInterface", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "ConnectRouterInterface", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// ConvertNatPublicIpToEip invokes the ecs.ConvertNatPublicIpToEip API synchronously
// api document: https://help.aliyun.com/api/ecs/convertnatpubliciptoeip.html
func (client *Client) ConvertNatPublicIpToEip(request *ConvertNatPublicIpToEipRequest) (response *ConvertNatPublicIpToEipResponse, err error) {
response = CreateConvertNatPublicIpToEipResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) ConvertNatPublicIpToEip(request *ConvertNatPublicIpToEipRe
}
// ConvertNatPublicIpToEipWithChan invokes the ecs.ConvertNatPublicIpToEip API asynchronously
// api document: https://help.aliyun.com/api/ecs/convertnatpubliciptoeip.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) ConvertNatPublicIpToEipWithChan(request *ConvertNatPublicIpToEipRequest) (<-chan *ConvertNatPublicIpToEipResponse, <-chan error) {
responseChan := make(chan *ConvertNatPublicIpToEipResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) ConvertNatPublicIpToEipWithChan(request *ConvertNatPublicI
}
// ConvertNatPublicIpToEipWithCallback invokes the ecs.ConvertNatPublicIpToEip API asynchronously
// api document: https://help.aliyun.com/api/ecs/convertnatpubliciptoeip.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) ConvertNatPublicIpToEipWithCallback(request *ConvertNatPublicIpToEipRequest, callback func(response *ConvertNatPublicIpToEipResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -93,7 +88,8 @@ func CreateConvertNatPublicIpToEipRequest() (request *ConvertNatPublicIpToEipReq
request = &ConvertNatPublicIpToEipRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "ConvertNatPublicIpToEip", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "ConvertNatPublicIpToEip", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CopyImage invokes the ecs.CopyImage API synchronously
// api document: https://help.aliyun.com/api/ecs/copyimage.html
func (client *Client) CopyImage(request *CopyImageRequest) (response *CopyImageResponse, err error) {
response = CreateCopyImageResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CopyImage(request *CopyImageRequest) (response *CopyImageR
}
// CopyImageWithChan invokes the ecs.CopyImage API asynchronously
// api document: https://help.aliyun.com/api/ecs/copyimage.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CopyImageWithChan(request *CopyImageRequest) (<-chan *CopyImageResponse, <-chan error) {
responseChan := make(chan *CopyImageResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CopyImageWithChan(request *CopyImageRequest) (<-chan *Copy
}
// CopyImageWithCallback invokes the ecs.CopyImage API asynchronously
// api document: https://help.aliyun.com/api/ecs/copyimage.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CopyImageWithCallback(request *CopyImageRequest, callback func(response *CopyImageResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -78,13 +73,16 @@ type CopyImageRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ImageId string `position:"Query" name:"ImageId"`
Encrypted requests.Boolean `position:"Query" name:"Encrypted"`
EncryptAlgorithm string `position:"Query" name:"EncryptAlgorithm"`
DestinationRegionId string `position:"Query" name:"DestinationRegionId"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
Tag *[]CopyImageTag `position:"Query" name:"Tag" type:"Repeated"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
DestinationImageName string `position:"Query" name:"DestinationImageName"`
DestinationRegionId string `position:"Query" name:"DestinationRegionId"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
Tag *[]CopyImageTag `position:"Query" name:"Tag" type:"Repeated"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
Encrypted requests.Boolean `position:"Query" name:"Encrypted"`
KMSKeyId string `position:"Query" name:"KMSKeyId"`
DestinationDescription string `position:"Query" name:"DestinationDescription"`
}
@@ -106,7 +104,8 @@ func CreateCopyImageRequest() (request *CopyImageRequest) {
request = &CopyImageRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CopyImage", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CopyImage", "", "")
request.Method = requests.POST
return
}

View File

@@ -0,0 +1,115 @@
package ecs
//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.
//
// Code generated by Alibaba Cloud SDK Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
)
// CopySnapshot invokes the ecs.CopySnapshot API synchronously
func (client *Client) CopySnapshot(request *CopySnapshotRequest) (response *CopySnapshotResponse, err error) {
response = CreateCopySnapshotResponse()
err = client.DoAction(request, response)
return
}
// CopySnapshotWithChan invokes the ecs.CopySnapshot API asynchronously
func (client *Client) CopySnapshotWithChan(request *CopySnapshotRequest) (<-chan *CopySnapshotResponse, <-chan error) {
responseChan := make(chan *CopySnapshotResponse, 1)
errChan := make(chan error, 1)
err := client.AddAsyncTask(func() {
defer close(responseChan)
defer close(errChan)
response, err := client.CopySnapshot(request)
if err != nil {
errChan <- err
} else {
responseChan <- response
}
})
if err != nil {
errChan <- err
close(responseChan)
close(errChan)
}
return responseChan, errChan
}
// CopySnapshotWithCallback invokes the ecs.CopySnapshot API asynchronously
func (client *Client) CopySnapshotWithCallback(request *CopySnapshotRequest, callback func(response *CopySnapshotResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
var response *CopySnapshotResponse
var err error
defer close(result)
response, err = client.CopySnapshot(request)
callback(response, err)
result <- 1
})
if err != nil {
defer close(result)
callback(nil, err)
result <- 0
}
return result
}
// CopySnapshotRequest is the request struct for api CopySnapshot
type CopySnapshotRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
SnapshotId string `position:"Query" name:"SnapshotId"`
DestinationRegionId string `position:"Query" name:"DestinationRegionId"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
Tag *[]CopySnapshotTag `position:"Query" name:"Tag" type:"Repeated"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
DestinationSnapshotName string `position:"Query" name:"DestinationSnapshotName"`
DestinationSnapshotDescription string `position:"Query" name:"DestinationSnapshotDescription"`
RetentionDays requests.Integer `position:"Query" name:"RetentionDays"`
}
// CopySnapshotTag is a repeated param struct in CopySnapshotRequest
type CopySnapshotTag struct {
Key string `name:"Key"`
Value string `name:"Value"`
}
// CopySnapshotResponse is the response struct for api CopySnapshot
type CopySnapshotResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
SnapshotId string `json:"SnapshotId" xml:"SnapshotId"`
}
// CreateCopySnapshotRequest creates a request to invoke CopySnapshot API
func CreateCopySnapshotRequest() (request *CopySnapshotRequest) {
request = &CopySnapshotRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CopySnapshot", "", "")
request.Method = requests.POST
return
}
// CreateCopySnapshotResponse creates a response to parse from CopySnapshot response
func CreateCopySnapshotResponse() (response *CopySnapshotResponse) {
response = &CopySnapshotResponse{
BaseResponse: &responses.BaseResponse{},
}
return
}

View File

@@ -0,0 +1,133 @@
package ecs
//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.
//
// Code generated by Alibaba Cloud SDK Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
)
// CreateAutoProvisioningGroup invokes the ecs.CreateAutoProvisioningGroup API synchronously
func (client *Client) CreateAutoProvisioningGroup(request *CreateAutoProvisioningGroupRequest) (response *CreateAutoProvisioningGroupResponse, err error) {
response = CreateCreateAutoProvisioningGroupResponse()
err = client.DoAction(request, response)
return
}
// CreateAutoProvisioningGroupWithChan invokes the ecs.CreateAutoProvisioningGroup API asynchronously
func (client *Client) CreateAutoProvisioningGroupWithChan(request *CreateAutoProvisioningGroupRequest) (<-chan *CreateAutoProvisioningGroupResponse, <-chan error) {
responseChan := make(chan *CreateAutoProvisioningGroupResponse, 1)
errChan := make(chan error, 1)
err := client.AddAsyncTask(func() {
defer close(responseChan)
defer close(errChan)
response, err := client.CreateAutoProvisioningGroup(request)
if err != nil {
errChan <- err
} else {
responseChan <- response
}
})
if err != nil {
errChan <- err
close(responseChan)
close(errChan)
}
return responseChan, errChan
}
// CreateAutoProvisioningGroupWithCallback invokes the ecs.CreateAutoProvisioningGroup API asynchronously
func (client *Client) CreateAutoProvisioningGroupWithCallback(request *CreateAutoProvisioningGroupRequest, callback func(response *CreateAutoProvisioningGroupResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
var response *CreateAutoProvisioningGroupResponse
var err error
defer close(result)
response, err = client.CreateAutoProvisioningGroup(request)
callback(response, err)
result <- 1
})
if err != nil {
defer close(result)
callback(nil, err)
result <- 0
}
return result
}
// CreateAutoProvisioningGroupRequest is the request struct for api CreateAutoProvisioningGroup
type CreateAutoProvisioningGroupRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
AutoProvisioningGroupType string `position:"Query" name:"AutoProvisioningGroupType"`
Description string `position:"Query" name:"Description"`
TerminateInstancesWithExpiration requests.Boolean `position:"Query" name:"TerminateInstancesWithExpiration"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
SpotAllocationStrategy string `position:"Query" name:"SpotAllocationStrategy"`
TerminateInstances requests.Boolean `position:"Query" name:"TerminateInstances"`
PayAsYouGoAllocationStrategy string `position:"Query" name:"PayAsYouGoAllocationStrategy"`
DefaultTargetCapacityType string `position:"Query" name:"DefaultTargetCapacityType"`
ExcessCapacityTerminationPolicy string `position:"Query" name:"ExcessCapacityTerminationPolicy"`
LaunchTemplateConfig *[]CreateAutoProvisioningGroupLaunchTemplateConfig `position:"Query" name:"LaunchTemplateConfig" type:"Repeated"`
ValidUntil string `position:"Query" name:"ValidUntil"`
SpotInstanceInterruptionBehavior string `position:"Query" name:"SpotInstanceInterruptionBehavior"`
LaunchTemplateId string `position:"Query" name:"LaunchTemplateId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
SpotInstancePoolsToUseCount requests.Integer `position:"Query" name:"SpotInstancePoolsToUseCount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
LaunchTemplateVersion string `position:"Query" name:"LaunchTemplateVersion"`
PayAsYouGoTargetCapacity string `position:"Query" name:"PayAsYouGoTargetCapacity"`
TotalTargetCapacity string `position:"Query" name:"TotalTargetCapacity"`
SpotTargetCapacity string `position:"Query" name:"SpotTargetCapacity"`
ValidFrom string `position:"Query" name:"ValidFrom"`
AutoProvisioningGroupName string `position:"Query" name:"AutoProvisioningGroupName"`
MaxSpotPrice requests.Float `position:"Query" name:"MaxSpotPrice"`
}
// CreateAutoProvisioningGroupLaunchTemplateConfig is a repeated param struct in CreateAutoProvisioningGroupRequest
type CreateAutoProvisioningGroupLaunchTemplateConfig struct {
InstanceType string `name:"InstanceType"`
MaxPrice string `name:"MaxPrice"`
VSwitchId string `name:"VSwitchId"`
WeightedCapacity string `name:"WeightedCapacity"`
Priority string `name:"Priority"`
}
// CreateAutoProvisioningGroupResponse is the response struct for api CreateAutoProvisioningGroup
type CreateAutoProvisioningGroupResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
AutoProvisioningGroupId string `json:"AutoProvisioningGroupId" xml:"AutoProvisioningGroupId"`
}
// CreateCreateAutoProvisioningGroupRequest creates a request to invoke CreateAutoProvisioningGroup API
func CreateCreateAutoProvisioningGroupRequest() (request *CreateAutoProvisioningGroupRequest) {
request = &CreateAutoProvisioningGroupRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateAutoProvisioningGroup", "", "")
request.Method = requests.POST
return
}
// CreateCreateAutoProvisioningGroupResponse creates a response to parse from CreateAutoProvisioningGroup response
func CreateCreateAutoProvisioningGroupResponse() (response *CreateAutoProvisioningGroupResponse) {
response = &CreateAutoProvisioningGroupResponse{
BaseResponse: &responses.BaseResponse{},
}
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateAutoSnapshotPolicy invokes the ecs.CreateAutoSnapshotPolicy API synchronously
// api document: https://help.aliyun.com/api/ecs/createautosnapshotpolicy.html
func (client *Client) CreateAutoSnapshotPolicy(request *CreateAutoSnapshotPolicyRequest) (response *CreateAutoSnapshotPolicyResponse, err error) {
response = CreateCreateAutoSnapshotPolicyResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateAutoSnapshotPolicy(request *CreateAutoSnapshotPolicy
}
// CreateAutoSnapshotPolicyWithChan invokes the ecs.CreateAutoSnapshotPolicy API asynchronously
// api document: https://help.aliyun.com/api/ecs/createautosnapshotpolicy.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateAutoSnapshotPolicyWithChan(request *CreateAutoSnapshotPolicyRequest) (<-chan *CreateAutoSnapshotPolicyResponse, <-chan error) {
responseChan := make(chan *CreateAutoSnapshotPolicyResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateAutoSnapshotPolicyWithChan(request *CreateAutoSnapsh
}
// CreateAutoSnapshotPolicyWithCallback invokes the ecs.CreateAutoSnapshotPolicy API asynchronously
// api document: https://help.aliyun.com/api/ecs/createautosnapshotpolicy.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateAutoSnapshotPolicyWithCallback(request *CreateAutoSnapshotPolicyRequest, callback func(response *CreateAutoSnapshotPolicyResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -76,13 +71,23 @@ func (client *Client) CreateAutoSnapshotPolicyWithCallback(request *CreateAutoSn
// CreateAutoSnapshotPolicyRequest is the request struct for api CreateAutoSnapshotPolicy
type CreateAutoSnapshotPolicyRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
TimePoints string `position:"Query" name:"timePoints"`
RetentionDays requests.Integer `position:"Query" name:"retentionDays"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
RepeatWeekdays string `position:"Query" name:"repeatWeekdays"`
AutoSnapshotPolicyName string `position:"Query" name:"autoSnapshotPolicyName"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
CopiedSnapshotsRetentionDays requests.Integer `position:"Query" name:"CopiedSnapshotsRetentionDays"`
TimePoints string `position:"Query" name:"timePoints"`
RepeatWeekdays string `position:"Query" name:"repeatWeekdays"`
Tag *[]CreateAutoSnapshotPolicyTag `position:"Query" name:"Tag" type:"Repeated"`
EnableCrossRegionCopy requests.Boolean `position:"Query" name:"EnableCrossRegionCopy"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
AutoSnapshotPolicyName string `position:"Query" name:"autoSnapshotPolicyName"`
RetentionDays requests.Integer `position:"Query" name:"retentionDays"`
TargetCopyRegions string `position:"Query" name:"TargetCopyRegions"`
}
// CreateAutoSnapshotPolicyTag is a repeated param struct in CreateAutoSnapshotPolicyRequest
type CreateAutoSnapshotPolicyTag struct {
Value string `name:"Value"`
Key string `name:"Key"`
}
// CreateAutoSnapshotPolicyResponse is the response struct for api CreateAutoSnapshotPolicy
@@ -97,7 +102,8 @@ func CreateCreateAutoSnapshotPolicyRequest() (request *CreateAutoSnapshotPolicyR
request = &CreateAutoSnapshotPolicyRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateAutoSnapshotPolicy", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateAutoSnapshotPolicy", "", "")
request.Method = requests.POST
return
}

View File

@@ -0,0 +1,122 @@
package ecs
//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.
//
// Code generated by Alibaba Cloud SDK Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
)
// CreateCapacityReservation invokes the ecs.CreateCapacityReservation API synchronously
func (client *Client) CreateCapacityReservation(request *CreateCapacityReservationRequest) (response *CreateCapacityReservationResponse, err error) {
response = CreateCreateCapacityReservationResponse()
err = client.DoAction(request, response)
return
}
// CreateCapacityReservationWithChan invokes the ecs.CreateCapacityReservation API asynchronously
func (client *Client) CreateCapacityReservationWithChan(request *CreateCapacityReservationRequest) (<-chan *CreateCapacityReservationResponse, <-chan error) {
responseChan := make(chan *CreateCapacityReservationResponse, 1)
errChan := make(chan error, 1)
err := client.AddAsyncTask(func() {
defer close(responseChan)
defer close(errChan)
response, err := client.CreateCapacityReservation(request)
if err != nil {
errChan <- err
} else {
responseChan <- response
}
})
if err != nil {
errChan <- err
close(responseChan)
close(errChan)
}
return responseChan, errChan
}
// CreateCapacityReservationWithCallback invokes the ecs.CreateCapacityReservation API asynchronously
func (client *Client) CreateCapacityReservationWithCallback(request *CreateCapacityReservationRequest, callback func(response *CreateCapacityReservationResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
var response *CreateCapacityReservationResponse
var err error
defer close(result)
response, err = client.CreateCapacityReservation(request)
callback(response, err)
result <- 1
})
if err != nil {
defer close(result)
callback(nil, err)
result <- 0
}
return result
}
// CreateCapacityReservationRequest is the request struct for api CreateCapacityReservation
type CreateCapacityReservationRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ClientToken string `position:"Query" name:"ClientToken"`
Description string `position:"Query" name:"Description"`
StartTime string `position:"Query" name:"StartTime"`
Platform string `position:"Query" name:"Platform"`
PrivatePoolOptionsMatchCriteria string `position:"Query" name:"PrivatePoolOptions.MatchCriteria"`
InstanceType string `position:"Query" name:"InstanceType"`
InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
EfficientStatus requests.Integer `position:"Query" name:"EfficientStatus"`
Period requests.Integer `position:"Query" name:"Period"`
EndTimeType string `position:"Query" name:"EndTimeType"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
PrivatePoolOptionsName string `position:"Query" name:"PrivatePoolOptions.Name"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
EndTime string `position:"Query" name:"EndTime"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
ResourceType string `position:"Query" name:"ResourceType"`
PeriodUnit string `position:"Query" name:"PeriodUnit"`
TimeSlot string `position:"Query" name:"TimeSlot"`
ZoneId *[]string `position:"Query" name:"ZoneId" type:"Repeated"`
ChargeType string `position:"Query" name:"ChargeType"`
PackageType string `position:"Query" name:"PackageType"`
InstanceAmount requests.Integer `position:"Query" name:"InstanceAmount"`
}
// CreateCapacityReservationResponse is the response struct for api CreateCapacityReservation
type CreateCapacityReservationResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
PrivatePoolOptionsId string `json:"PrivatePoolOptionsId" xml:"PrivatePoolOptionsId"`
}
// CreateCreateCapacityReservationRequest creates a request to invoke CreateCapacityReservation API
func CreateCreateCapacityReservationRequest() (request *CreateCapacityReservationRequest) {
request = &CreateCapacityReservationRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateCapacityReservation", "", "")
request.Method = requests.POST
return
}
// CreateCreateCapacityReservationResponse creates a response to parse from CreateCapacityReservation response
func CreateCreateCapacityReservationResponse() (response *CreateCapacityReservationResponse) {
response = &CreateCapacityReservationResponse{
BaseResponse: &responses.BaseResponse{},
}
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateCommand invokes the ecs.CreateCommand API synchronously
// api document: https://help.aliyun.com/api/ecs/createcommand.html
func (client *Client) CreateCommand(request *CreateCommandRequest) (response *CreateCommandResponse, err error) {
response = CreateCreateCommandResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateCommand(request *CreateCommandRequest) (response *Cr
}
// CreateCommandWithChan invokes the ecs.CreateCommand API asynchronously
// api document: https://help.aliyun.com/api/ecs/createcommand.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateCommandWithChan(request *CreateCommandRequest) (<-chan *CreateCommandResponse, <-chan error) {
responseChan := make(chan *CreateCommandResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateCommandWithChan(request *CreateCommandRequest) (<-ch
}
// CreateCommandWithCallback invokes the ecs.CreateCommand API asynchronously
// api document: https://help.aliyun.com/api/ecs/createcommand.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateCommandWithCallback(request *CreateCommandRequest, callback func(response *CreateCommandResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -86,6 +81,7 @@ type CreateCommandRequest struct {
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
Name string `position:"Query" name:"Name"`
EnableParameter requests.Boolean `position:"Query" name:"EnableParameter"`
}
// CreateCommandResponse is the response struct for api CreateCommand
@@ -100,7 +96,8 @@ func CreateCreateCommandRequest() (request *CreateCommandRequest) {
request = &CreateCommandRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateCommand", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateCommand", "", "")
request.Method = requests.POST
return
}

View File

@@ -0,0 +1,115 @@
package ecs
//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.
//
// Code generated by Alibaba Cloud SDK Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
)
// CreateDedicatedHostCluster invokes the ecs.CreateDedicatedHostCluster API synchronously
func (client *Client) CreateDedicatedHostCluster(request *CreateDedicatedHostClusterRequest) (response *CreateDedicatedHostClusterResponse, err error) {
response = CreateCreateDedicatedHostClusterResponse()
err = client.DoAction(request, response)
return
}
// CreateDedicatedHostClusterWithChan invokes the ecs.CreateDedicatedHostCluster API asynchronously
func (client *Client) CreateDedicatedHostClusterWithChan(request *CreateDedicatedHostClusterRequest) (<-chan *CreateDedicatedHostClusterResponse, <-chan error) {
responseChan := make(chan *CreateDedicatedHostClusterResponse, 1)
errChan := make(chan error, 1)
err := client.AddAsyncTask(func() {
defer close(responseChan)
defer close(errChan)
response, err := client.CreateDedicatedHostCluster(request)
if err != nil {
errChan <- err
} else {
responseChan <- response
}
})
if err != nil {
errChan <- err
close(responseChan)
close(errChan)
}
return responseChan, errChan
}
// CreateDedicatedHostClusterWithCallback invokes the ecs.CreateDedicatedHostCluster API asynchronously
func (client *Client) CreateDedicatedHostClusterWithCallback(request *CreateDedicatedHostClusterRequest, callback func(response *CreateDedicatedHostClusterResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
var response *CreateDedicatedHostClusterResponse
var err error
defer close(result)
response, err = client.CreateDedicatedHostCluster(request)
callback(response, err)
result <- 1
})
if err != nil {
defer close(result)
callback(nil, err)
result <- 0
}
return result
}
// CreateDedicatedHostClusterRequest is the request struct for api CreateDedicatedHostCluster
type CreateDedicatedHostClusterRequest struct {
*requests.RpcRequest
DedicatedHostClusterName string `position:"Query" name:"DedicatedHostClusterName"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
Description string `position:"Query" name:"Description"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
Tag *[]CreateDedicatedHostClusterTag `position:"Query" name:"Tag" type:"Repeated"`
DryRun requests.Boolean `position:"Query" name:"DryRun"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
ZoneId string `position:"Query" name:"ZoneId"`
}
// CreateDedicatedHostClusterTag is a repeated param struct in CreateDedicatedHostClusterRequest
type CreateDedicatedHostClusterTag struct {
Key string `name:"Key"`
Value string `name:"Value"`
}
// CreateDedicatedHostClusterResponse is the response struct for api CreateDedicatedHostCluster
type CreateDedicatedHostClusterResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
DedicatedHostClusterId string `json:"DedicatedHostClusterId" xml:"DedicatedHostClusterId"`
}
// CreateCreateDedicatedHostClusterRequest creates a request to invoke CreateDedicatedHostCluster API
func CreateCreateDedicatedHostClusterRequest() (request *CreateDedicatedHostClusterRequest) {
request = &CreateDedicatedHostClusterRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateDedicatedHostCluster", "", "")
request.Method = requests.POST
return
}
// CreateCreateDedicatedHostClusterResponse creates a response to parse from CreateDedicatedHostCluster response
func CreateCreateDedicatedHostClusterResponse() (response *CreateDedicatedHostClusterResponse) {
response = &CreateDedicatedHostClusterResponse{
BaseResponse: &responses.BaseResponse{},
}
return
}

View File

@@ -0,0 +1,114 @@
package ecs
//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.
//
// Code generated by Alibaba Cloud SDK Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
)
// CreateDemand invokes the ecs.CreateDemand API synchronously
func (client *Client) CreateDemand(request *CreateDemandRequest) (response *CreateDemandResponse, err error) {
response = CreateCreateDemandResponse()
err = client.DoAction(request, response)
return
}
// CreateDemandWithChan invokes the ecs.CreateDemand API asynchronously
func (client *Client) CreateDemandWithChan(request *CreateDemandRequest) (<-chan *CreateDemandResponse, <-chan error) {
responseChan := make(chan *CreateDemandResponse, 1)
errChan := make(chan error, 1)
err := client.AddAsyncTask(func() {
defer close(responseChan)
defer close(errChan)
response, err := client.CreateDemand(request)
if err != nil {
errChan <- err
} else {
responseChan <- response
}
})
if err != nil {
errChan <- err
close(responseChan)
close(errChan)
}
return responseChan, errChan
}
// CreateDemandWithCallback invokes the ecs.CreateDemand API asynchronously
func (client *Client) CreateDemandWithCallback(request *CreateDemandRequest, callback func(response *CreateDemandResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
var response *CreateDemandResponse
var err error
defer close(result)
response, err = client.CreateDemand(request)
callback(response, err)
result <- 1
})
if err != nil {
defer close(result)
callback(nil, err)
result <- 0
}
return result
}
// CreateDemandRequest is the request struct for api CreateDemand
type CreateDemandRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ClientToken string `position:"Query" name:"ClientToken"`
StartTime string `position:"Query" name:"StartTime"`
DemandDescription string `position:"Query" name:"DemandDescription"`
InstanceType string `position:"Query" name:"InstanceType"`
InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
DemandName string `position:"Query" name:"DemandName"`
Amount requests.Integer `position:"Query" name:"Amount"`
Period requests.Integer `position:"Query" name:"Period"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
EndTime string `position:"Query" name:"EndTime"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
PeriodUnit string `position:"Query" name:"PeriodUnit"`
ZoneId string `position:"Query" name:"ZoneId"`
}
// CreateDemandResponse is the response struct for api CreateDemand
type CreateDemandResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
DemandId string `json:"DemandId" xml:"DemandId"`
}
// CreateCreateDemandRequest creates a request to invoke CreateDemand API
func CreateCreateDemandRequest() (request *CreateDemandRequest) {
request = &CreateDemandRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateDemand", "", "")
request.Method = requests.POST
return
}
// CreateCreateDemandResponse creates a response to parse from CreateDemand response
func CreateCreateDemandResponse() (response *CreateDemandResponse) {
response = &CreateDemandResponse{
BaseResponse: &responses.BaseResponse{},
}
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateDeploymentSet invokes the ecs.CreateDeploymentSet API synchronously
// api document: https://help.aliyun.com/api/ecs/createdeploymentset.html
func (client *Client) CreateDeploymentSet(request *CreateDeploymentSetRequest) (response *CreateDeploymentSetResponse, err error) {
response = CreateCreateDeploymentSetResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateDeploymentSet(request *CreateDeploymentSetRequest) (
}
// CreateDeploymentSetWithChan invokes the ecs.CreateDeploymentSet API asynchronously
// api document: https://help.aliyun.com/api/ecs/createdeploymentset.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateDeploymentSetWithChan(request *CreateDeploymentSetRequest) (<-chan *CreateDeploymentSetResponse, <-chan error) {
responseChan := make(chan *CreateDeploymentSetResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateDeploymentSetWithChan(request *CreateDeploymentSetRe
}
// CreateDeploymentSetWithCallback invokes the ecs.CreateDeploymentSet API asynchronously
// api document: https://help.aliyun.com/api/ecs/createdeploymentset.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateDeploymentSetWithCallback(request *CreateDeploymentSetRequest, callback func(response *CreateDeploymentSetResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,10 +72,11 @@ func (client *Client) CreateDeploymentSetWithCallback(request *CreateDeploymentS
type CreateDeploymentSetRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
ClientToken string `position:"Query" name:"ClientToken"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
Description string `position:"Query" name:"Description"`
GroupCount requests.Integer `position:"Query" name:"GroupCount"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
DeploymentSetName string `position:"Query" name:"DeploymentSetName"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
OnUnableToRedeployFailedInstance string `position:"Query" name:"OnUnableToRedeployFailedInstance"`
@@ -101,7 +97,8 @@ func CreateCreateDeploymentSetRequest() (request *CreateDeploymentSetRequest) {
request = &CreateDeploymentSetRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateDeploymentSet", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateDeploymentSet", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateDisk invokes the ecs.CreateDisk API synchronously
// api document: https://help.aliyun.com/api/ecs/createdisk.html
func (client *Client) CreateDisk(request *CreateDiskRequest) (response *CreateDiskResponse, err error) {
response = CreateCreateDiskResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateDisk(request *CreateDiskRequest) (response *CreateDi
}
// CreateDiskWithChan invokes the ecs.CreateDisk API asynchronously
// api document: https://help.aliyun.com/api/ecs/createdisk.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateDiskWithChan(request *CreateDiskRequest) (<-chan *CreateDiskResponse, <-chan error) {
responseChan := make(chan *CreateDiskResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateDiskWithChan(request *CreateDiskRequest) (<-chan *Cr
}
// CreateDiskWithCallback invokes the ecs.CreateDisk API asynchronously
// api document: https://help.aliyun.com/api/ecs/createdisk.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateDiskWithCallback(request *CreateDiskRequest, callback func(response *CreateDiskResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -76,20 +71,28 @@ func (client *Client) CreateDiskWithCallback(request *CreateDiskRequest, callbac
// CreateDiskRequest is the request struct for api CreateDisk
type CreateDiskRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
SnapshotId string `position:"Query" name:"SnapshotId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
ClientToken string `position:"Query" name:"ClientToken"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
Description string `position:"Query" name:"Description"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
DiskName string `position:"Query" name:"DiskName"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
Size requests.Integer `position:"Query" name:"Size"`
Encrypted requests.Boolean `position:"Query" name:"Encrypted"`
DiskCategory string `position:"Query" name:"DiskCategory"`
ZoneId string `position:"Query" name:"ZoneId"`
Tag *[]CreateDiskTag `position:"Query" name:"Tag" type:"Repeated"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
SnapshotId string `position:"Query" name:"SnapshotId"`
ClientToken string `position:"Query" name:"ClientToken"`
EncryptAlgorithm string `position:"Query" name:"EncryptAlgorithm"`
Description string `position:"Query" name:"Description"`
DiskName string `position:"Query" name:"DiskName"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
DiskCategory string `position:"Query" name:"DiskCategory"`
StorageSetPartitionNumber requests.Integer `position:"Query" name:"StorageSetPartitionNumber"`
Tag *[]CreateDiskTag `position:"Query" name:"Tag" type:"Repeated"`
Arn *[]CreateDiskArn `position:"Query" name:"Arn" type:"Repeated"`
AdvancedFeatures string `position:"Query" name:"AdvancedFeatures"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
PerformanceLevel string `position:"Query" name:"PerformanceLevel"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
StorageSetId string `position:"Query" name:"StorageSetId"`
Size requests.Integer `position:"Query" name:"Size"`
Encrypted requests.Boolean `position:"Query" name:"Encrypted"`
ZoneId string `position:"Query" name:"ZoneId"`
KMSKeyId string `position:"Query" name:"KMSKeyId"`
}
// CreateDiskTag is a repeated param struct in CreateDiskRequest
@@ -98,6 +101,13 @@ type CreateDiskTag struct {
Key string `name:"Key"`
}
// CreateDiskArn is a repeated param struct in CreateDiskRequest
type CreateDiskArn struct {
Rolearn string `name:"Rolearn"`
RoleType string `name:"RoleType"`
AssumeRoleFor string `name:"AssumeRoleFor"`
}
// CreateDiskResponse is the response struct for api CreateDisk
type CreateDiskResponse struct {
*responses.BaseResponse
@@ -110,7 +120,8 @@ func CreateCreateDiskRequest() (request *CreateDiskRequest) {
request = &CreateDiskRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateDisk", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateDisk", "", "")
request.Method = requests.POST
return
}

View File

@@ -0,0 +1,121 @@
package ecs
//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.
//
// Code generated by Alibaba Cloud SDK Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
)
// CreateElasticityAssurance invokes the ecs.CreateElasticityAssurance API synchronously
func (client *Client) CreateElasticityAssurance(request *CreateElasticityAssuranceRequest) (response *CreateElasticityAssuranceResponse, err error) {
response = CreateCreateElasticityAssuranceResponse()
err = client.DoAction(request, response)
return
}
// CreateElasticityAssuranceWithChan invokes the ecs.CreateElasticityAssurance API asynchronously
func (client *Client) CreateElasticityAssuranceWithChan(request *CreateElasticityAssuranceRequest) (<-chan *CreateElasticityAssuranceResponse, <-chan error) {
responseChan := make(chan *CreateElasticityAssuranceResponse, 1)
errChan := make(chan error, 1)
err := client.AddAsyncTask(func() {
defer close(responseChan)
defer close(errChan)
response, err := client.CreateElasticityAssurance(request)
if err != nil {
errChan <- err
} else {
responseChan <- response
}
})
if err != nil {
errChan <- err
close(responseChan)
close(errChan)
}
return responseChan, errChan
}
// CreateElasticityAssuranceWithCallback invokes the ecs.CreateElasticityAssurance API asynchronously
func (client *Client) CreateElasticityAssuranceWithCallback(request *CreateElasticityAssuranceRequest, callback func(response *CreateElasticityAssuranceResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
var response *CreateElasticityAssuranceResponse
var err error
defer close(result)
response, err = client.CreateElasticityAssurance(request)
callback(response, err)
result <- 1
})
if err != nil {
defer close(result)
callback(nil, err)
result <- 0
}
return result
}
// CreateElasticityAssuranceRequest is the request struct for api CreateElasticityAssurance
type CreateElasticityAssuranceRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ClientToken string `position:"Query" name:"ClientToken"`
Description string `position:"Query" name:"Description"`
StartTime string `position:"Query" name:"StartTime"`
Platform string `position:"Query" name:"Platform"`
PrivatePoolOptionsMatchCriteria string `position:"Query" name:"PrivatePoolOptions.MatchCriteria"`
InstanceType *[]string `position:"Query" name:"InstanceType" type:"Repeated"`
InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
Period requests.Integer `position:"Query" name:"Period"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
PrivatePoolOptionsName string `position:"Query" name:"PrivatePoolOptions.Name"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
AssuranceTimes string `position:"Query" name:"AssuranceTimes"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
ResourceType string `position:"Query" name:"ResourceType"`
InstanceCpuCoreCount requests.Integer `position:"Query" name:"InstanceCpuCoreCount"`
PeriodUnit string `position:"Query" name:"PeriodUnit"`
ZoneId *[]string `position:"Query" name:"ZoneId" type:"Repeated"`
ChargeType string `position:"Query" name:"ChargeType"`
PackageType string `position:"Query" name:"PackageType"`
InstanceAmount requests.Integer `position:"Query" name:"InstanceAmount"`
}
// CreateElasticityAssuranceResponse is the response struct for api CreateElasticityAssurance
type CreateElasticityAssuranceResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
PrivatePoolOptionsId string `json:"PrivatePoolOptionsId" xml:"PrivatePoolOptionsId"`
OrderId string `json:"OrderId" xml:"OrderId"`
}
// CreateCreateElasticityAssuranceRequest creates a request to invoke CreateElasticityAssurance API
func CreateCreateElasticityAssuranceRequest() (request *CreateElasticityAssuranceRequest) {
request = &CreateElasticityAssuranceRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateElasticityAssurance", "", "")
request.Method = requests.POST
return
}
// CreateCreateElasticityAssuranceResponse creates a response to parse from CreateElasticityAssurance response
func CreateCreateElasticityAssuranceResponse() (response *CreateElasticityAssuranceResponse) {
response = &CreateElasticityAssuranceResponse{
BaseResponse: &responses.BaseResponse{},
}
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateForwardEntry invokes the ecs.CreateForwardEntry API synchronously
// api document: https://help.aliyun.com/api/ecs/createforwardentry.html
func (client *Client) CreateForwardEntry(request *CreateForwardEntryRequest) (response *CreateForwardEntryResponse, err error) {
response = CreateCreateForwardEntryResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateForwardEntry(request *CreateForwardEntryRequest) (re
}
// CreateForwardEntryWithChan invokes the ecs.CreateForwardEntry API asynchronously
// api document: https://help.aliyun.com/api/ecs/createforwardentry.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateForwardEntryWithChan(request *CreateForwardEntryRequest) (<-chan *CreateForwardEntryResponse, <-chan error) {
responseChan := make(chan *CreateForwardEntryResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateForwardEntryWithChan(request *CreateForwardEntryRequ
}
// CreateForwardEntryWithCallback invokes the ecs.CreateForwardEntry API asynchronously
// api document: https://help.aliyun.com/api/ecs/createforwardentry.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateForwardEntryWithCallback(request *CreateForwardEntryRequest, callback func(response *CreateForwardEntryResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,15 +72,15 @@ func (client *Client) CreateForwardEntryWithCallback(request *CreateForwardEntry
type CreateForwardEntryRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ForwardTableId string `position:"Query" name:"ForwardTableId"`
InternalIp string `position:"Query" name:"InternalIp"`
ExternalIp string `position:"Query" name:"ExternalIp"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
IpProtocol string `position:"Query" name:"IpProtocol"`
InternalPort string `position:"Query" name:"InternalPort"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
ForwardTableId string `position:"Query" name:"ForwardTableId"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
ExternalIp string `position:"Query" name:"ExternalIp"`
InternalPort string `position:"Query" name:"InternalPort"`
ExternalPort string `position:"Query" name:"ExternalPort"`
InternalIp string `position:"Query" name:"InternalIp"`
}
// CreateForwardEntryResponse is the response struct for api CreateForwardEntry
@@ -100,7 +95,8 @@ func CreateCreateForwardEntryRequest() (request *CreateForwardEntryRequest) {
request = &CreateForwardEntryRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateForwardEntry", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateForwardEntry", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateHaVip invokes the ecs.CreateHaVip API synchronously
// api document: https://help.aliyun.com/api/ecs/createhavip.html
func (client *Client) CreateHaVip(request *CreateHaVipRequest) (response *CreateHaVipResponse, err error) {
response = CreateCreateHaVipResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateHaVip(request *CreateHaVipRequest) (response *Create
}
// CreateHaVipWithChan invokes the ecs.CreateHaVip API asynchronously
// api document: https://help.aliyun.com/api/ecs/createhavip.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateHaVipWithChan(request *CreateHaVipRequest) (<-chan *CreateHaVipResponse, <-chan error) {
responseChan := make(chan *CreateHaVipResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateHaVipWithChan(request *CreateHaVipRequest) (<-chan *
}
// CreateHaVipWithCallback invokes the ecs.CreateHaVip API asynchronously
// api document: https://help.aliyun.com/api/ecs/createhavip.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateHaVipWithCallback(request *CreateHaVipRequest, callback func(response *CreateHaVipResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -76,14 +71,14 @@ func (client *Client) CreateHaVipWithCallback(request *CreateHaVipRequest, callb
// CreateHaVipRequest is the request struct for api CreateHaVip
type CreateHaVipRequest struct {
*requests.RpcRequest
VSwitchId string `position:"Query" name:"VSwitchId"`
IpAddress string `position:"Query" name:"IpAddress"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
ClientToken string `position:"Query" name:"ClientToken"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
Description string `position:"Query" name:"Description"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
VSwitchId string `position:"Query" name:"VSwitchId"`
}
// CreateHaVipResponse is the response struct for api CreateHaVip
@@ -98,7 +93,8 @@ func CreateCreateHaVipRequest() (request *CreateHaVipRequest) {
request = &CreateHaVipRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateHaVip", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateHaVip", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateHpcCluster invokes the ecs.CreateHpcCluster API synchronously
// api document: https://help.aliyun.com/api/ecs/createhpccluster.html
func (client *Client) CreateHpcCluster(request *CreateHpcClusterRequest) (response *CreateHpcClusterResponse, err error) {
response = CreateCreateHpcClusterResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateHpcCluster(request *CreateHpcClusterRequest) (respon
}
// CreateHpcClusterWithChan invokes the ecs.CreateHpcCluster API asynchronously
// api document: https://help.aliyun.com/api/ecs/createhpccluster.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateHpcClusterWithChan(request *CreateHpcClusterRequest) (<-chan *CreateHpcClusterResponse, <-chan error) {
responseChan := make(chan *CreateHpcClusterResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateHpcClusterWithChan(request *CreateHpcClusterRequest)
}
// CreateHpcClusterWithCallback invokes the ecs.CreateHpcCluster API asynchronously
// api document: https://help.aliyun.com/api/ecs/createhpccluster.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateHpcClusterWithCallback(request *CreateHpcClusterRequest, callback func(response *CreateHpcClusterResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -97,7 +92,8 @@ func CreateCreateHpcClusterRequest() (request *CreateHpcClusterRequest) {
request = &CreateHpcClusterRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateHpcCluster", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateHpcCluster", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateImage invokes the ecs.CreateImage API synchronously
// api document: https://help.aliyun.com/api/ecs/createimage.html
func (client *Client) CreateImage(request *CreateImageRequest) (response *CreateImageResponse, err error) {
response = CreateCreateImageResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateImage(request *CreateImageRequest) (response *Create
}
// CreateImageWithChan invokes the ecs.CreateImage API asynchronously
// api document: https://help.aliyun.com/api/ecs/createimage.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateImageWithChan(request *CreateImageRequest) (<-chan *CreateImageResponse, <-chan error) {
responseChan := make(chan *CreateImageResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateImageWithChan(request *CreateImageRequest) (<-chan *
}
// CreateImageWithCallback invokes the ecs.CreateImage API asynchronously
// api document: https://help.aliyun.com/api/ecs/createimage.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateImageWithCallback(request *CreateImageRequest, callback func(response *CreateImageResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -79,18 +74,19 @@ type CreateImageRequest struct {
DiskDeviceMapping *[]CreateImageDiskDeviceMapping `position:"Query" name:"DiskDeviceMapping" type:"Repeated"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
SnapshotId string `position:"Query" name:"SnapshotId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
ClientToken string `position:"Query" name:"ClientToken"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
Description string `position:"Query" name:"Description"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
Platform string `position:"Query" name:"Platform"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
InstanceId string `position:"Query" name:"InstanceId"`
ImageName string `position:"Query" name:"ImageName"`
ImageVersion string `position:"Query" name:"ImageVersion"`
Tag *[]CreateImageTag `position:"Query" name:"Tag" type:"Repeated"`
Architecture string `position:"Query" name:"Architecture"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
InstanceId string `position:"Query" name:"InstanceId"`
ImageFamily string `position:"Query" name:"ImageFamily"`
ImageVersion string `position:"Query" name:"ImageVersion"`
}
// CreateImageDiskDeviceMapping is a repeated param struct in CreateImageRequest
@@ -119,7 +115,8 @@ func CreateCreateImageRequest() (request *CreateImageRequest) {
request = &CreateImageRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateImage", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateImage", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateInstance invokes the ecs.CreateInstance API synchronously
// api document: https://help.aliyun.com/api/ecs/createinstance.html
func (client *Client) CreateInstance(request *CreateInstanceRequest) (response *CreateInstanceResponse, err error) {
response = CreateCreateInstanceResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateInstance(request *CreateInstanceRequest) (response *
}
// CreateInstanceWithChan invokes the ecs.CreateInstance API asynchronously
// api document: https://help.aliyun.com/api/ecs/createinstance.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateInstanceWithChan(request *CreateInstanceRequest) (<-chan *CreateInstanceResponse, <-chan error) {
responseChan := make(chan *CreateInstanceResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateInstanceWithChan(request *CreateInstanceRequest) (<-
}
// CreateInstanceWithCallback invokes the ecs.CreateInstance API asynchronously
// api document: https://help.aliyun.com/api/ecs/createinstance.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateInstanceWithCallback(request *CreateInstanceRequest, callback func(response *CreateInstanceResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -76,55 +71,72 @@ func (client *Client) CreateInstanceWithCallback(request *CreateInstanceRequest,
// CreateInstanceRequest is the request struct for api CreateInstance
type CreateInstanceRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
HpcClusterId string `position:"Query" name:"HpcClusterId"`
SecurityEnhancementStrategy string `position:"Query" name:"SecurityEnhancementStrategy"`
KeyPairName string `position:"Query" name:"KeyPairName"`
SpotPriceLimit requests.Float `position:"Query" name:"SpotPriceLimit"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
HostName string `position:"Query" name:"HostName"`
Password string `position:"Query" name:"Password"`
Tag *[]CreateInstanceTag `position:"Query" name:"Tag" type:"Repeated"`
AutoRenewPeriod requests.Integer `position:"Query" name:"AutoRenewPeriod"`
NodeControllerId string `position:"Query" name:"NodeControllerId"`
Period requests.Integer `position:"Query" name:"Period"`
DryRun requests.Boolean `position:"Query" name:"DryRun"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
VSwitchId string `position:"Query" name:"VSwitchId"`
PrivateIpAddress string `position:"Query" name:"PrivateIpAddress"`
SpotStrategy string `position:"Query" name:"SpotStrategy"`
PeriodUnit string `position:"Query" name:"PeriodUnit"`
InstanceName string `position:"Query" name:"InstanceName"`
AutoRenew requests.Boolean `position:"Query" name:"AutoRenew"`
InternetChargeType string `position:"Query" name:"InternetChargeType"`
ZoneId string `position:"Query" name:"ZoneId"`
InternetMaxBandwidthIn requests.Integer `position:"Query" name:"InternetMaxBandwidthIn"`
UseAdditionalService requests.Boolean `position:"Query" name:"UseAdditionalService"`
ImageId string `position:"Query" name:"ImageId"`
ClientToken string `position:"Query" name:"ClientToken"`
VlanId string `position:"Query" name:"VlanId"`
SpotInterruptionBehavior string `position:"Query" name:"SpotInterruptionBehavior"`
IoOptimized string `position:"Query" name:"IoOptimized"`
SecurityGroupId string `position:"Query" name:"SecurityGroupId"`
InternetMaxBandwidthOut requests.Integer `position:"Query" name:"InternetMaxBandwidthOut"`
Description string `position:"Query" name:"Description"`
SystemDiskCategory string `position:"Query" name:"SystemDisk.Category"`
UserData string `position:"Query" name:"UserData"`
PasswordInherit requests.Boolean `position:"Query" name:"PasswordInherit"`
InstanceType string `position:"Query" name:"InstanceType"`
InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
DeploymentSetId string `position:"Query" name:"DeploymentSetId"`
InnerIpAddress string `position:"Query" name:"InnerIpAddress"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
SystemDiskDiskName string `position:"Query" name:"SystemDisk.DiskName"`
RamRoleName string `position:"Query" name:"RamRoleName"`
DedicatedHostId string `position:"Query" name:"DedicatedHostId"`
ClusterId string `position:"Query" name:"ClusterId"`
CreditSpecification string `position:"Query" name:"CreditSpecification"`
DataDisk *[]CreateInstanceDataDisk `position:"Query" name:"DataDisk" type:"Repeated"`
SystemDiskSize requests.Integer `position:"Query" name:"SystemDisk.Size"`
SystemDiskDescription string `position:"Query" name:"SystemDisk.Description"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
HpcClusterId string `position:"Query" name:"HpcClusterId"`
HttpPutResponseHopLimit requests.Integer `position:"Query" name:"HttpPutResponseHopLimit"`
SecurityEnhancementStrategy string `position:"Query" name:"SecurityEnhancementStrategy"`
KeyPairName string `position:"Query" name:"KeyPairName"`
SpotPriceLimit requests.Float `position:"Query" name:"SpotPriceLimit"`
DeletionProtection requests.Boolean `position:"Query" name:"DeletionProtection"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
PrivatePoolOptionsMatchCriteria string `position:"Query" name:"PrivatePoolOptions.MatchCriteria"`
HostName string `position:"Query" name:"HostName"`
Password string `position:"Query" name:"Password"`
DeploymentSetGroupNo requests.Integer `position:"Query" name:"DeploymentSetGroupNo"`
StorageSetPartitionNumber requests.Integer `position:"Query" name:"StorageSetPartitionNumber"`
Tag *[]CreateInstanceTag `position:"Query" name:"Tag" type:"Repeated"`
PrivatePoolOptionsId string `position:"Query" name:"PrivatePoolOptions.Id"`
AutoRenewPeriod requests.Integer `position:"Query" name:"AutoRenewPeriod"`
NodeControllerId string `position:"Query" name:"NodeControllerId"`
Period requests.Integer `position:"Query" name:"Period"`
DryRun requests.Boolean `position:"Query" name:"DryRun"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
CapacityReservationPreference string `position:"Query" name:"CapacityReservationPreference"`
VSwitchId string `position:"Query" name:"VSwitchId"`
PrivateIpAddress string `position:"Query" name:"PrivateIpAddress"`
SpotStrategy string `position:"Query" name:"SpotStrategy"`
PeriodUnit string `position:"Query" name:"PeriodUnit"`
InstanceName string `position:"Query" name:"InstanceName"`
AutoRenew requests.Boolean `position:"Query" name:"AutoRenew"`
InternetChargeType string `position:"Query" name:"InternetChargeType"`
ZoneId string `position:"Query" name:"ZoneId"`
InternetMaxBandwidthIn requests.Integer `position:"Query" name:"InternetMaxBandwidthIn"`
UseAdditionalService requests.Boolean `position:"Query" name:"UseAdditionalService"`
Affinity string `position:"Query" name:"Affinity"`
ImageId string `position:"Query" name:"ImageId"`
ClientToken string `position:"Query" name:"ClientToken"`
VlanId string `position:"Query" name:"VlanId"`
SpotInterruptionBehavior string `position:"Query" name:"SpotInterruptionBehavior"`
IoOptimized string `position:"Query" name:"IoOptimized"`
SecurityGroupId string `position:"Query" name:"SecurityGroupId"`
InternetMaxBandwidthOut requests.Integer `position:"Query" name:"InternetMaxBandwidthOut"`
Description string `position:"Query" name:"Description"`
SystemDiskCategory string `position:"Query" name:"SystemDisk.Category"`
CapacityReservationId string `position:"Query" name:"CapacityReservationId"`
SystemDiskPerformanceLevel string `position:"Query" name:"SystemDisk.PerformanceLevel"`
UserData string `position:"Query" name:"UserData"`
PasswordInherit requests.Boolean `position:"Query" name:"PasswordInherit"`
HttpEndpoint string `position:"Query" name:"HttpEndpoint"`
InstanceType string `position:"Query" name:"InstanceType"`
Arn *[]CreateInstanceArn `position:"Query" name:"Arn" type:"Repeated"`
InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
DeploymentSetId string `position:"Query" name:"DeploymentSetId"`
InnerIpAddress string `position:"Query" name:"InnerIpAddress"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
Tenancy string `position:"Query" name:"Tenancy"`
SystemDiskDiskName string `position:"Query" name:"SystemDisk.DiskName"`
RamRoleName string `position:"Query" name:"RamRoleName"`
DedicatedHostId string `position:"Query" name:"DedicatedHostId"`
ClusterId string `position:"Query" name:"ClusterId"`
CreditSpecification string `position:"Query" name:"CreditSpecification"`
SpotDuration requests.Integer `position:"Query" name:"SpotDuration"`
DataDisk *[]CreateInstanceDataDisk `position:"Query" name:"DataDisk" type:"Repeated"`
StorageSetId string `position:"Query" name:"StorageSetId"`
SystemDiskSize requests.Integer `position:"Query" name:"SystemDisk.Size"`
ImageFamily string `position:"Query" name:"ImageFamily"`
HttpTokens string `position:"Query" name:"HttpTokens"`
SystemDiskDescription string `position:"Query" name:"SystemDisk.Description"`
}
// CreateInstanceTag is a repeated param struct in CreateInstanceRequest
@@ -133,14 +145,24 @@ type CreateInstanceTag struct {
Key string `name:"Key"`
}
// CreateInstanceArn is a repeated param struct in CreateInstanceRequest
type CreateInstanceArn struct {
Rolearn string `name:"Rolearn"`
RoleType string `name:"RoleType"`
AssumeRoleFor string `name:"AssumeRoleFor"`
}
// CreateInstanceDataDisk is a repeated param struct in CreateInstanceRequest
type CreateInstanceDataDisk struct {
DiskName string `name:"DiskName"`
SnapshotId string `name:"SnapshotId"`
Size string `name:"Size"`
Encrypted string `name:"Encrypted"`
PerformanceLevel string `name:"PerformanceLevel"`
EncryptAlgorithm string `name:"EncryptAlgorithm"`
Description string `name:"Description"`
Category string `name:"Category"`
KMSKeyId string `name:"KMSKeyId"`
Device string `name:"Device"`
DeleteWithInstance string `name:"DeleteWithInstance"`
}
@@ -148,8 +170,9 @@ type CreateInstanceDataDisk struct {
// CreateInstanceResponse is the response struct for api CreateInstance
type CreateInstanceResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
InstanceId string `json:"InstanceId" xml:"InstanceId"`
RequestId string `json:"RequestId" xml:"RequestId"`
InstanceId string `json:"InstanceId" xml:"InstanceId"`
TradePrice float64 `json:"TradePrice" xml:"TradePrice"`
}
// CreateCreateInstanceRequest creates a request to invoke CreateInstance API
@@ -157,7 +180,8 @@ func CreateCreateInstanceRequest() (request *CreateInstanceRequest) {
request = &CreateInstanceRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateInstance", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateInstance", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateKeyPair invokes the ecs.CreateKeyPair API synchronously
// api document: https://help.aliyun.com/api/ecs/createkeypair.html
func (client *Client) CreateKeyPair(request *CreateKeyPairRequest) (response *CreateKeyPairResponse, err error) {
response = CreateCreateKeyPairResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateKeyPair(request *CreateKeyPairRequest) (response *Cr
}
// CreateKeyPairWithChan invokes the ecs.CreateKeyPair API asynchronously
// api document: https://help.aliyun.com/api/ecs/createkeypair.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateKeyPairWithChan(request *CreateKeyPairRequest) (<-chan *CreateKeyPairResponse, <-chan error) {
responseChan := make(chan *CreateKeyPairResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateKeyPairWithChan(request *CreateKeyPairRequest) (<-ch
}
// CreateKeyPairWithCallback invokes the ecs.CreateKeyPair API asynchronously
// api document: https://help.aliyun.com/api/ecs/createkeypair.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateKeyPairWithCallback(request *CreateKeyPairRequest, callback func(response *CreateKeyPairResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -76,11 +71,11 @@ func (client *Client) CreateKeyPairWithCallback(request *CreateKeyPairRequest, c
// CreateKeyPairRequest is the request struct for api CreateKeyPair
type CreateKeyPairRequest struct {
*requests.RpcRequest
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
KeyPairName string `position:"Query" name:"KeyPairName"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
Tag *[]CreateKeyPairTag `position:"Query" name:"Tag" type:"Repeated"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
}
@@ -94,6 +89,7 @@ type CreateKeyPairTag struct {
type CreateKeyPairResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
KeyPairId string `json:"KeyPairId" xml:"KeyPairId"`
KeyPairName string `json:"KeyPairName" xml:"KeyPairName"`
KeyPairFingerPrint string `json:"KeyPairFingerPrint" xml:"KeyPairFingerPrint"`
PrivateKeyBody string `json:"PrivateKeyBody" xml:"PrivateKeyBody"`
@@ -104,7 +100,8 @@ func CreateCreateKeyPairRequest() (request *CreateKeyPairRequest) {
request = &CreateKeyPairRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateKeyPair", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateKeyPair", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateLaunchTemplate invokes the ecs.CreateLaunchTemplate API synchronously
// api document: https://help.aliyun.com/api/ecs/createlaunchtemplate.html
func (client *Client) CreateLaunchTemplate(request *CreateLaunchTemplateRequest) (response *CreateLaunchTemplateResponse, err error) {
response = CreateCreateLaunchTemplateResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateLaunchTemplate(request *CreateLaunchTemplateRequest)
}
// CreateLaunchTemplateWithChan invokes the ecs.CreateLaunchTemplate API asynchronously
// api document: https://help.aliyun.com/api/ecs/createlaunchtemplate.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateLaunchTemplateWithChan(request *CreateLaunchTemplateRequest) (<-chan *CreateLaunchTemplateResponse, <-chan error) {
responseChan := make(chan *CreateLaunchTemplateResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateLaunchTemplateWithChan(request *CreateLaunchTemplate
}
// CreateLaunchTemplateWithCallback invokes the ecs.CreateLaunchTemplate API asynchronously
// api document: https://help.aliyun.com/api/ecs/createlaunchtemplate.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateLaunchTemplateWithCallback(request *CreateLaunchTemplateRequest, callback func(response *CreateLaunchTemplateResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -105,6 +100,7 @@ type CreateLaunchTemplateRequest struct {
Description string `position:"Query" name:"Description"`
SystemDiskCategory string `position:"Query" name:"SystemDisk.Category"`
UserData string `position:"Query" name:"UserData"`
PasswordInherit requests.Boolean `position:"Query" name:"PasswordInherit"`
InstanceType string `position:"Query" name:"InstanceType"`
InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
EnableVmOsConfig requests.Boolean `position:"Query" name:"EnableVmOsConfig"`
@@ -151,6 +147,7 @@ type CreateLaunchTemplateDataDisk struct {
DiskName string `name:"DiskName"`
Description string `name:"Description"`
DeleteWithInstance string `name:"DeleteWithInstance"`
Device string `name:"Device"`
}
// CreateLaunchTemplateResponse is the response struct for api CreateLaunchTemplate
@@ -165,7 +162,8 @@ func CreateCreateLaunchTemplateRequest() (request *CreateLaunchTemplateRequest)
request = &CreateLaunchTemplateRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateLaunchTemplate", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateLaunchTemplate", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateLaunchTemplateVersion invokes the ecs.CreateLaunchTemplateVersion API synchronously
// api document: https://help.aliyun.com/api/ecs/createlaunchtemplateversion.html
func (client *Client) CreateLaunchTemplateVersion(request *CreateLaunchTemplateVersionRequest) (response *CreateLaunchTemplateVersionResponse, err error) {
response = CreateCreateLaunchTemplateVersionResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateLaunchTemplateVersion(request *CreateLaunchTemplateV
}
// CreateLaunchTemplateVersionWithChan invokes the ecs.CreateLaunchTemplateVersion API asynchronously
// api document: https://help.aliyun.com/api/ecs/createlaunchtemplateversion.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateLaunchTemplateVersionWithChan(request *CreateLaunchTemplateVersionRequest) (<-chan *CreateLaunchTemplateVersionResponse, <-chan error) {
responseChan := make(chan *CreateLaunchTemplateVersionResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateLaunchTemplateVersionWithChan(request *CreateLaunchT
}
// CreateLaunchTemplateVersionWithCallback invokes the ecs.CreateLaunchTemplateVersion API asynchronously
// api document: https://help.aliyun.com/api/ecs/createlaunchtemplateversion.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateLaunchTemplateVersionWithCallback(request *CreateLaunchTemplateVersionRequest, callback func(response *CreateLaunchTemplateVersionResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -104,6 +99,7 @@ type CreateLaunchTemplateVersionRequest struct {
Description string `position:"Query" name:"Description"`
SystemDiskCategory string `position:"Query" name:"SystemDisk.Category"`
UserData string `position:"Query" name:"UserData"`
PasswordInherit requests.Boolean `position:"Query" name:"PasswordInherit"`
InstanceType string `position:"Query" name:"InstanceType"`
InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
EnableVmOsConfig requests.Boolean `position:"Query" name:"EnableVmOsConfig"`
@@ -144,13 +140,14 @@ type CreateLaunchTemplateVersionDataDisk struct {
DiskName string `name:"DiskName"`
Description string `name:"Description"`
DeleteWithInstance string `name:"DeleteWithInstance"`
Device string `name:"Device"`
}
// CreateLaunchTemplateVersionResponse is the response struct for api CreateLaunchTemplateVersion
type CreateLaunchTemplateVersionResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
LaunchTemplateVersionNumber int `json:"LaunchTemplateVersionNumber" xml:"LaunchTemplateVersionNumber"`
LaunchTemplateVersionNumber int64 `json:"LaunchTemplateVersionNumber" xml:"LaunchTemplateVersionNumber"`
}
// CreateCreateLaunchTemplateVersionRequest creates a request to invoke CreateLaunchTemplateVersion API
@@ -158,7 +155,8 @@ func CreateCreateLaunchTemplateVersionRequest() (request *CreateLaunchTemplateVe
request = &CreateLaunchTemplateVersionRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateLaunchTemplateVersion", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateLaunchTemplateVersion", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateNatGateway invokes the ecs.CreateNatGateway API synchronously
// api document: https://help.aliyun.com/api/ecs/createnatgateway.html
func (client *Client) CreateNatGateway(request *CreateNatGatewayRequest) (response *CreateNatGatewayResponse, err error) {
response = CreateCreateNatGatewayResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateNatGateway(request *CreateNatGatewayRequest) (respon
}
// CreateNatGatewayWithChan invokes the ecs.CreateNatGateway API asynchronously
// api document: https://help.aliyun.com/api/ecs/createnatgateway.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateNatGatewayWithChan(request *CreateNatGatewayRequest) (<-chan *CreateNatGatewayResponse, <-chan error) {
responseChan := make(chan *CreateNatGatewayResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateNatGatewayWithChan(request *CreateNatGatewayRequest)
}
// CreateNatGatewayWithCallback invokes the ecs.CreateNatGateway API asynchronously
// api document: https://help.aliyun.com/api/ecs/createnatgateway.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateNatGatewayWithCallback(request *CreateNatGatewayRequest, callback func(response *CreateNatGatewayResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,14 +72,14 @@ func (client *Client) CreateNatGatewayWithCallback(request *CreateNatGatewayRequ
type CreateNatGatewayRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
ClientToken string `position:"Query" name:"ClientToken"`
Description string `position:"Query" name:"Description"`
BandwidthPackage *[]CreateNatGatewayBandwidthPackage `position:"Query" name:"BandwidthPackage" type:"Repeated"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
VpcId string `position:"Query" name:"VpcId"`
Name string `position:"Query" name:"Name"`
Description string `position:"Query" name:"Description"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
BandwidthPackage *[]CreateNatGatewayBandwidthPackage `position:"Query" name:"BandwidthPackage" type:"Repeated"`
}
// CreateNatGatewayBandwidthPackage is a repeated param struct in CreateNatGatewayRequest
@@ -108,7 +103,8 @@ func CreateCreateNatGatewayRequest() (request *CreateNatGatewayRequest) {
request = &CreateNatGatewayRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateNatGateway", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateNatGateway", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateNetworkInterface invokes the ecs.CreateNetworkInterface API synchronously
// api document: https://help.aliyun.com/api/ecs/createnetworkinterface.html
func (client *Client) CreateNetworkInterface(request *CreateNetworkInterfaceRequest) (response *CreateNetworkInterfaceResponse, err error) {
response = CreateCreateNetworkInterfaceResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateNetworkInterface(request *CreateNetworkInterfaceRequ
}
// CreateNetworkInterfaceWithChan invokes the ecs.CreateNetworkInterface API asynchronously
// api document: https://help.aliyun.com/api/ecs/createnetworkinterface.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateNetworkInterfaceWithChan(request *CreateNetworkInterfaceRequest) (<-chan *CreateNetworkInterfaceResponse, <-chan error) {
responseChan := make(chan *CreateNetworkInterfaceResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateNetworkInterfaceWithChan(request *CreateNetworkInter
}
// CreateNetworkInterfaceWithCallback invokes the ecs.CreateNetworkInterface API asynchronously
// api document: https://help.aliyun.com/api/ecs/createnetworkinterface.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateNetworkInterfaceWithCallback(request *CreateNetworkInterfaceRequest, callback func(response *CreateNetworkInterfaceResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -76,18 +71,25 @@ func (client *Client) CreateNetworkInterfaceWithCallback(request *CreateNetworkI
// CreateNetworkInterfaceRequest is the request struct for api CreateNetworkInterface
type CreateNetworkInterfaceRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ClientToken string `position:"Query" name:"ClientToken"`
SecurityGroupId string `position:"Query" name:"SecurityGroupId"`
Description string `position:"Query" name:"Description"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
Tag *[]CreateNetworkInterfaceTag `position:"Query" name:"Tag" type:"Repeated"`
NetworkInterfaceName string `position:"Query" name:"NetworkInterfaceName"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
VSwitchId string `position:"Query" name:"VSwitchId"`
PrimaryIpAddress string `position:"Query" name:"PrimaryIpAddress"`
QueueNumber requests.Integer `position:"Query" name:"QueueNumber"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ClientToken string `position:"Query" name:"ClientToken"`
SecurityGroupId string `position:"Query" name:"SecurityGroupId"`
Description string `position:"Query" name:"Description"`
SecondaryPrivateIpAddressCount requests.Integer `position:"Query" name:"SecondaryPrivateIpAddressCount"`
BusinessType string `position:"Query" name:"BusinessType"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
InstanceType string `position:"Query" name:"InstanceType"`
Tag *[]CreateNetworkInterfaceTag `position:"Query" name:"Tag" type:"Repeated"`
NetworkInterfaceName string `position:"Query" name:"NetworkInterfaceName"`
Visible requests.Boolean `position:"Query" name:"Visible"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
SecurityGroupIds *[]string `position:"Query" name:"SecurityGroupIds" type:"Repeated"`
VSwitchId string `position:"Query" name:"VSwitchId"`
PrivateIpAddress *[]string `position:"Query" name:"PrivateIpAddress" type:"Repeated"`
PrimaryIpAddress string `position:"Query" name:"PrimaryIpAddress"`
}
// CreateNetworkInterfaceTag is a repeated param struct in CreateNetworkInterfaceRequest
@@ -99,8 +101,24 @@ type CreateNetworkInterfaceTag struct {
// CreateNetworkInterfaceResponse is the response struct for api CreateNetworkInterface
type CreateNetworkInterfaceResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
NetworkInterfaceId string `json:"NetworkInterfaceId" xml:"NetworkInterfaceId"`
RequestId string `json:"RequestId" xml:"RequestId"`
NetworkInterfaceId string `json:"NetworkInterfaceId" xml:"NetworkInterfaceId"`
Status string `json:"Status" xml:"Status"`
Type string `json:"Type" xml:"Type"`
VpcId string `json:"VpcId" xml:"VpcId"`
VSwitchId string `json:"VSwitchId" xml:"VSwitchId"`
ZoneId string `json:"ZoneId" xml:"ZoneId"`
PrivateIpAddress string `json:"PrivateIpAddress" xml:"PrivateIpAddress"`
MacAddress string `json:"MacAddress" xml:"MacAddress"`
NetworkInterfaceName string `json:"NetworkInterfaceName" xml:"NetworkInterfaceName"`
Description string `json:"Description" xml:"Description"`
ResourceGroupId string `json:"ResourceGroupId" xml:"ResourceGroupId"`
ServiceID int64 `json:"ServiceID" xml:"ServiceID"`
ServiceManaged bool `json:"ServiceManaged" xml:"ServiceManaged"`
OwnerId string `json:"OwnerId" xml:"OwnerId"`
SecurityGroupIds SecurityGroupIdsInCreateNetworkInterface `json:"SecurityGroupIds" xml:"SecurityGroupIds"`
PrivateIpSets PrivateIpSetsInCreateNetworkInterface `json:"PrivateIpSets" xml:"PrivateIpSets"`
Tags TagsInCreateNetworkInterface `json:"Tags" xml:"Tags"`
}
// CreateCreateNetworkInterfaceRequest creates a request to invoke CreateNetworkInterface API
@@ -108,7 +126,8 @@ func CreateCreateNetworkInterfaceRequest() (request *CreateNetworkInterfaceReque
request = &CreateNetworkInterfaceRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateNetworkInterface", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateNetworkInterface", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateNetworkInterfacePermission invokes the ecs.CreateNetworkInterfacePermission API synchronously
// api document: https://help.aliyun.com/api/ecs/createnetworkinterfacepermission.html
func (client *Client) CreateNetworkInterfacePermission(request *CreateNetworkInterfacePermissionRequest) (response *CreateNetworkInterfacePermissionResponse, err error) {
response = CreateCreateNetworkInterfacePermissionResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateNetworkInterfacePermission(request *CreateNetworkInt
}
// CreateNetworkInterfacePermissionWithChan invokes the ecs.CreateNetworkInterfacePermission API asynchronously
// api document: https://help.aliyun.com/api/ecs/createnetworkinterfacepermission.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateNetworkInterfacePermissionWithChan(request *CreateNetworkInterfacePermissionRequest) (<-chan *CreateNetworkInterfacePermissionResponse, <-chan error) {
responseChan := make(chan *CreateNetworkInterfacePermissionResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateNetworkInterfacePermissionWithChan(request *CreateNe
}
// CreateNetworkInterfacePermissionWithCallback invokes the ecs.CreateNetworkInterfacePermission API asynchronously
// api document: https://help.aliyun.com/api/ecs/createnetworkinterfacepermission.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateNetworkInterfacePermissionWithCallback(request *CreateNetworkInterfacePermissionRequest, callback func(response *CreateNetworkInterfacePermissionResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -97,7 +92,8 @@ func CreateCreateNetworkInterfacePermissionRequest() (request *CreateNetworkInte
request = &CreateNetworkInterfacePermissionRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateNetworkInterfacePermission", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateNetworkInterfacePermission", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreatePhysicalConnection invokes the ecs.CreatePhysicalConnection API synchronously
// api document: https://help.aliyun.com/api/ecs/createphysicalconnection.html
func (client *Client) CreatePhysicalConnection(request *CreatePhysicalConnectionRequest) (response *CreatePhysicalConnectionResponse, err error) {
response = CreateCreatePhysicalConnectionResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreatePhysicalConnection(request *CreatePhysicalConnection
}
// CreatePhysicalConnectionWithChan invokes the ecs.CreatePhysicalConnection API asynchronously
// api document: https://help.aliyun.com/api/ecs/createphysicalconnection.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreatePhysicalConnectionWithChan(request *CreatePhysicalConnectionRequest) (<-chan *CreatePhysicalConnectionResponse, <-chan error) {
responseChan := make(chan *CreatePhysicalConnectionResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreatePhysicalConnectionWithChan(request *CreatePhysicalCo
}
// CreatePhysicalConnectionWithCallback invokes the ecs.CreatePhysicalConnection API asynchronously
// api document: https://help.aliyun.com/api/ecs/createphysicalconnection.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreatePhysicalConnectionWithCallback(request *CreatePhysicalConnectionRequest, callback func(response *CreatePhysicalConnectionResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,21 +72,21 @@ func (client *Client) CreatePhysicalConnectionWithCallback(request *CreatePhysic
type CreatePhysicalConnectionRequest struct {
*requests.RpcRequest
AccessPointId string `position:"Query" name:"AccessPointId"`
RedundantPhysicalConnectionId string `position:"Query" name:"RedundantPhysicalConnectionId"`
PeerLocation string `position:"Query" name:"PeerLocation"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
PortType string `position:"Query" name:"PortType"`
CircuitCode string `position:"Query" name:"CircuitCode"`
Bandwidth requests.Integer `position:"Query" name:"bandwidth"`
ClientToken string `position:"Query" name:"ClientToken"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
Description string `position:"Query" name:"Description"`
Type string `position:"Query" name:"Type"`
UserCidr string `position:"Query" name:"UserCidr"`
RedundantPhysicalConnectionId string `position:"Query" name:"RedundantPhysicalConnectionId"`
PeerLocation string `position:"Query" name:"PeerLocation"`
Bandwidth requests.Integer `position:"Query" name:"bandwidth"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
LineOperator string `position:"Query" name:"LineOperator"`
Name string `position:"Query" name:"Name"`
UserCidr string `position:"Query" name:"UserCidr"`
}
// CreatePhysicalConnectionResponse is the response struct for api CreatePhysicalConnection
@@ -106,7 +101,8 @@ func CreateCreatePhysicalConnectionRequest() (request *CreatePhysicalConnectionR
request = &CreatePhysicalConnectionRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreatePhysicalConnection", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreatePhysicalConnection", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateRouteEntry invokes the ecs.CreateRouteEntry API synchronously
// api document: https://help.aliyun.com/api/ecs/createrouteentry.html
func (client *Client) CreateRouteEntry(request *CreateRouteEntryRequest) (response *CreateRouteEntryResponse, err error) {
response = CreateCreateRouteEntryResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateRouteEntry(request *CreateRouteEntryRequest) (respon
}
// CreateRouteEntryWithChan invokes the ecs.CreateRouteEntry API asynchronously
// api document: https://help.aliyun.com/api/ecs/createrouteentry.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateRouteEntryWithChan(request *CreateRouteEntryRequest) (<-chan *CreateRouteEntryResponse, <-chan error) {
responseChan := make(chan *CreateRouteEntryResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateRouteEntryWithChan(request *CreateRouteEntryRequest)
}
// CreateRouteEntryWithCallback invokes the ecs.CreateRouteEntry API asynchronously
// api document: https://help.aliyun.com/api/ecs/createrouteentry.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateRouteEntryWithCallback(request *CreateRouteEntryRequest, callback func(response *CreateRouteEntryResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,15 +72,15 @@ func (client *Client) CreateRouteEntryWithCallback(request *CreateRouteEntryRequ
type CreateRouteEntryRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
ClientToken string `position:"Query" name:"ClientToken"`
NextHopId string `position:"Query" name:"NextHopId"`
NextHopType string `position:"Query" name:"NextHopType"`
RouteTableId string `position:"Query" name:"RouteTableId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
DestinationCidrBlock string `position:"Query" name:"DestinationCidrBlock"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
NextHopId string `position:"Query" name:"NextHopId"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
NextHopType string `position:"Query" name:"NextHopType"`
NextHopList *[]CreateRouteEntryNextHopList `position:"Query" name:"NextHopList" type:"Repeated"`
RouteTableId string `position:"Query" name:"RouteTableId"`
}
// CreateRouteEntryNextHopList is a repeated param struct in CreateRouteEntryRequest
@@ -105,7 +100,8 @@ func CreateCreateRouteEntryRequest() (request *CreateRouteEntryRequest) {
request = &CreateRouteEntryRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateRouteEntry", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateRouteEntry", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateRouterInterface invokes the ecs.CreateRouterInterface API synchronously
// api document: https://help.aliyun.com/api/ecs/createrouterinterface.html
func (client *Client) CreateRouterInterface(request *CreateRouterInterfaceRequest) (response *CreateRouterInterfaceResponse, err error) {
response = CreateCreateRouterInterfaceResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateRouterInterface(request *CreateRouterInterfaceReques
}
// CreateRouterInterfaceWithChan invokes the ecs.CreateRouterInterface API asynchronously
// api document: https://help.aliyun.com/api/ecs/createrouterinterface.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateRouterInterfaceWithChan(request *CreateRouterInterfaceRequest) (<-chan *CreateRouterInterfaceResponse, <-chan error) {
responseChan := make(chan *CreateRouterInterfaceResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateRouterInterfaceWithChan(request *CreateRouterInterfa
}
// CreateRouterInterfaceWithCallback invokes the ecs.CreateRouterInterface API asynchronously
// api document: https://help.aliyun.com/api/ecs/createrouterinterface.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateRouterInterfaceWithCallback(request *CreateRouterInterfaceRequest, callback func(response *CreateRouterInterfaceResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -108,7 +103,7 @@ type CreateRouterInterfaceResponse struct {
*responses.BaseResponse
RequestId string `json:"RequestId" xml:"RequestId"`
RouterInterfaceId string `json:"RouterInterfaceId" xml:"RouterInterfaceId"`
OrderId int `json:"OrderId" xml:"OrderId"`
OrderId int64 `json:"OrderId" xml:"OrderId"`
}
// CreateCreateRouterInterfaceRequest creates a request to invoke CreateRouterInterface API
@@ -116,7 +111,8 @@ func CreateCreateRouterInterfaceRequest() (request *CreateRouterInterfaceRequest
request = &CreateRouterInterfaceRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateRouterInterface", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateRouterInterface", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateSecurityGroup invokes the ecs.CreateSecurityGroup API synchronously
// api document: https://help.aliyun.com/api/ecs/createsecuritygroup.html
func (client *Client) CreateSecurityGroup(request *CreateSecurityGroupRequest) (response *CreateSecurityGroupResponse, err error) {
response = CreateCreateSecurityGroupResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateSecurityGroup(request *CreateSecurityGroupRequest) (
}
// CreateSecurityGroupWithChan invokes the ecs.CreateSecurityGroup API asynchronously
// api document: https://help.aliyun.com/api/ecs/createsecuritygroup.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateSecurityGroupWithChan(request *CreateSecurityGroupRequest) (<-chan *CreateSecurityGroupResponse, <-chan error) {
responseChan := make(chan *CreateSecurityGroupResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateSecurityGroupWithChan(request *CreateSecurityGroupRe
}
// CreateSecurityGroupWithCallback invokes the ecs.CreateSecurityGroup API asynchronously
// api document: https://help.aliyun.com/api/ecs/createsecuritygroup.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateSecurityGroupWithCallback(request *CreateSecurityGroupRequest, callback func(response *CreateSecurityGroupResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -76,16 +71,18 @@ func (client *Client) CreateSecurityGroupWithCallback(request *CreateSecurityGro
// CreateSecurityGroupRequest is the request struct for api CreateSecurityGroup
type CreateSecurityGroupRequest struct {
*requests.RpcRequest
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
ClientToken string `position:"Query" name:"ClientToken"`
VpcId string `position:"Query" name:"VpcId"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
ServiceManaged requests.Boolean `position:"Query" name:"ServiceManaged"`
Description string `position:"Query" name:"Description"`
Tag *[]CreateSecurityGroupTag `position:"Query" name:"Tag" type:"Repeated"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
SecurityGroupName string `position:"Query" name:"SecurityGroupName"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
Tag *[]CreateSecurityGroupTag `position:"Query" name:"Tag" type:"Repeated"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
SecurityGroupType string `position:"Query" name:"SecurityGroupType"`
VpcId string `position:"Query" name:"VpcId"`
}
// CreateSecurityGroupTag is a repeated param struct in CreateSecurityGroupRequest
@@ -106,7 +103,8 @@ func CreateCreateSecurityGroupRequest() (request *CreateSecurityGroupRequest) {
request = &CreateSecurityGroupRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateSecurityGroup", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateSecurityGroup", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateSimulatedSystemEvents invokes the ecs.CreateSimulatedSystemEvents API synchronously
// api document: https://help.aliyun.com/api/ecs/createsimulatedsystemevents.html
func (client *Client) CreateSimulatedSystemEvents(request *CreateSimulatedSystemEventsRequest) (response *CreateSimulatedSystemEventsResponse, err error) {
response = CreateCreateSimulatedSystemEventsResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateSimulatedSystemEvents(request *CreateSimulatedSystem
}
// CreateSimulatedSystemEventsWithChan invokes the ecs.CreateSimulatedSystemEvents API asynchronously
// api document: https://help.aliyun.com/api/ecs/createsimulatedsystemevents.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateSimulatedSystemEventsWithChan(request *CreateSimulatedSystemEventsRequest) (<-chan *CreateSimulatedSystemEventsResponse, <-chan error) {
responseChan := make(chan *CreateSimulatedSystemEventsResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateSimulatedSystemEventsWithChan(request *CreateSimulat
}
// CreateSimulatedSystemEventsWithCallback invokes the ecs.CreateSimulatedSystemEvents API asynchronously
// api document: https://help.aliyun.com/api/ecs/createsimulatedsystemevents.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateSimulatedSystemEventsWithCallback(request *CreateSimulatedSystemEventsRequest, callback func(response *CreateSimulatedSystemEventsResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -97,7 +92,8 @@ func CreateCreateSimulatedSystemEventsRequest() (request *CreateSimulatedSystemE
request = &CreateSimulatedSystemEventsRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateSimulatedSystemEvents", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateSimulatedSystemEvents", "", "")
request.Method = requests.POST
return
}

View File

@@ -21,7 +21,6 @@ import (
)
// CreateSnapshot invokes the ecs.CreateSnapshot API synchronously
// api document: https://help.aliyun.com/api/ecs/createsnapshot.html
func (client *Client) CreateSnapshot(request *CreateSnapshotRequest) (response *CreateSnapshotResponse, err error) {
response = CreateCreateSnapshotResponse()
err = client.DoAction(request, response)
@@ -29,8 +28,6 @@ func (client *Client) CreateSnapshot(request *CreateSnapshotRequest) (response *
}
// CreateSnapshotWithChan invokes the ecs.CreateSnapshot API asynchronously
// api document: https://help.aliyun.com/api/ecs/createsnapshot.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateSnapshotWithChan(request *CreateSnapshotRequest) (<-chan *CreateSnapshotResponse, <-chan error) {
responseChan := make(chan *CreateSnapshotResponse, 1)
errChan := make(chan error, 1)
@@ -53,8 +50,6 @@ func (client *Client) CreateSnapshotWithChan(request *CreateSnapshotRequest) (<-
}
// CreateSnapshotWithCallback invokes the ecs.CreateSnapshot API asynchronously
// api document: https://help.aliyun.com/api/ecs/createsnapshot.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateSnapshotWithCallback(request *CreateSnapshotRequest, callback func(response *CreateSnapshotResponse, err error)) <-chan int {
result := make(chan int, 1)
err := client.AddAsyncTask(func() {
@@ -77,14 +72,17 @@ func (client *Client) CreateSnapshotWithCallback(request *CreateSnapshotRequest,
type CreateSnapshotRequest struct {
*requests.RpcRequest
ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
ClientToken string `position:"Query" name:"ClientToken"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
Description string `position:"Query" name:"Description"`
DiskId string `position:"Query" name:"DiskId"`
SnapshotName string `position:"Query" name:"SnapshotName"`
ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
DiskId string `position:"Query" name:"DiskId"`
Tag *[]CreateSnapshotTag `position:"Query" name:"Tag" type:"Repeated"`
ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
OwnerAccount string `position:"Query" name:"OwnerAccount"`
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
RetentionDays requests.Integer `position:"Query" name:"RetentionDays"`
Category string `position:"Query" name:"Category"`
}
// CreateSnapshotTag is a repeated param struct in CreateSnapshotRequest
@@ -105,7 +103,8 @@ func CreateCreateSnapshotRequest() (request *CreateSnapshotRequest) {
request = &CreateSnapshotRequest{
RpcRequest: &requests.RpcRequest{},
}
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateSnapshot", "ecs", "openAPI")
request.InitWithApiInfo("Ecs", "2014-05-26", "CreateSnapshot", "", "")
request.Method = requests.POST
return
}

Some files were not shown because too many files have changed in this diff Show More