mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #13848 from ioito/hotfix/qx-account-permission
fix(region): show account lake of permission
This commit is contained in:
@@ -15,7 +15,10 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/gotypes"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
@@ -333,6 +336,9 @@ type CloudaccountUpdateInput struct {
|
||||
SAMLAuth *bool `json:"saml_auth"`
|
||||
|
||||
proxyapi.ProxySettingResourceInput
|
||||
|
||||
// 临时清除缺失的权限提示,云账号权限缺失依然会自动刷新
|
||||
CleanLakeOfPermissions bool `json:"clean_lake_of_permissions"`
|
||||
}
|
||||
|
||||
type CloudaccountPerformPublicInput struct {
|
||||
@@ -503,3 +509,23 @@ type SyncRangeInput struct {
|
||||
// enmu: compute, network, loadbalancer, objectstore, rds, cache, nat, nas, waf, mongodb, es, kafka, app, container
|
||||
Resources []string `json:"resources" choices:"compute|network|loadbalancer|objectstore|rds|cache|nat|nas|waf|mongodb|es|kafka|app|container"`
|
||||
}
|
||||
|
||||
type SAccountPermission struct {
|
||||
Permissions []string
|
||||
}
|
||||
|
||||
type SAccountPermissions map[string]SAccountPermission
|
||||
|
||||
func (s SAccountPermissions) String() string {
|
||||
return jsonutils.Marshal(s).String()
|
||||
}
|
||||
|
||||
func (s SAccountPermissions) IsZero() bool {
|
||||
return len(s) == 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
gotypes.RegisterSerializable(reflect.TypeOf(&SAccountPermissions{}), func() gotypes.ISerializable {
|
||||
return &SAccountPermissions{}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -172,6 +172,8 @@ type ProviderConfig struct {
|
||||
|
||||
DefaultRegion string
|
||||
ProxyFunc httputils.TransportProxyFunc
|
||||
|
||||
UpdatePermission func(service, permission string)
|
||||
}
|
||||
|
||||
func (cp *ProviderConfig) AdaptiveTimeoutHttpClient() *http.Client {
|
||||
|
||||
@@ -168,6 +168,9 @@ type SCloudaccount struct {
|
||||
|
||||
// 设置允许同步的账号及订阅
|
||||
SubAccounts *cloudprovider.SubAccounts `nullable:"true" get:"user" create:"optional"`
|
||||
|
||||
// 缺失的权限,云账号操作资源时自动更新
|
||||
LakeOfPermissions api.SAccountPermissions `length:"medium" get:"user" list:"user"`
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) GetCloudproviders() []SCloudprovider {
|
||||
@@ -357,6 +360,12 @@ func (self *SCloudaccount) PostUpdate(ctx context.Context, userCred mcclient.Tok
|
||||
if input.Options != nil {
|
||||
logclient.AddSimpleActionLog(self, logclient.ACT_UPDATE_BILLING_OPTIONS, input.Options, userCred, true)
|
||||
}
|
||||
if input.CleanLakeOfPermissions {
|
||||
db.Update(self, func() error {
|
||||
self.LakeOfPermissions = nil
|
||||
return nil
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (manager *SCloudaccountManager) ValidateCreateData(
|
||||
@@ -936,11 +945,39 @@ func (self *SCloudaccount) proxyFunc() httputils.TransportProxyFunc {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) UpdatePermission() func(string, string) {
|
||||
return func(service, permission string) {
|
||||
ctx, key := context.Background(), "update permission"
|
||||
|
||||
lockman.LockRawObject(ctx, self.Id, key)
|
||||
defer lockman.ReleaseRawObject(ctx, self.Id, key)
|
||||
|
||||
db.Update(self, func() error {
|
||||
if self.LakeOfPermissions == nil {
|
||||
self.LakeOfPermissions = api.SAccountPermissions{}
|
||||
}
|
||||
_, ok := self.LakeOfPermissions[service]
|
||||
if !ok {
|
||||
self.LakeOfPermissions[service] = api.SAccountPermission{}
|
||||
}
|
||||
permissions := self.LakeOfPermissions[service].Permissions
|
||||
if !utils.IsInStringArray(permission, permissions) {
|
||||
permissions = append(permissions, permission)
|
||||
self.LakeOfPermissions[service] = api.SAccountPermission{
|
||||
Permissions: permissions,
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) getProviderInternal() (cloudprovider.ICloudProvider, error) {
|
||||
secret, err := self.getPassword()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Invalid password %s", err)
|
||||
}
|
||||
|
||||
defaultRegion, _ := jsonutils.Marshal(self.Options).GetString("default_region")
|
||||
return cloudprovider.GetProvider(cloudprovider.ProviderConfig{
|
||||
Id: self.Id,
|
||||
@@ -953,6 +990,8 @@ func (self *SCloudaccount) getProviderInternal() (cloudprovider.ICloudProvider,
|
||||
Options: self.Options,
|
||||
DefaultRegion: defaultRegion,
|
||||
ProxyFunc: self.proxyFunc(),
|
||||
|
||||
UpdatePermission: self.UpdatePermission(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -872,6 +872,8 @@ func (self *SCloudprovider) GetProvider() (cloudprovider.ICloudProvider, error)
|
||||
|
||||
DefaultRegion: defaultRegion,
|
||||
Options: account.Options,
|
||||
|
||||
UpdatePermission: account.UpdatePermission(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ const (
|
||||
ErrIncorrectUsernameOrPassword = errors.Error("IncorrectUsernameOrPassword")
|
||||
|
||||
ErrInvalidAccessKey = errors.Error("InvalidAccessKey")
|
||||
ErrNoPermission = errors.Error("NoPermission")
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -560,6 +560,8 @@ type SCloudAccountUpdateBaseOptions struct {
|
||||
ProxySetting string `help:"proxy setting name or id" json:"proxy_setting"`
|
||||
SamlAuth string `help:"Enable or disable saml auth" choices:"true|false"`
|
||||
|
||||
CleanLakeOfPermissions bool `help:"clean lake of permissions"`
|
||||
|
||||
Desc string `help:"Description" json:"description" token:"desc"`
|
||||
}
|
||||
|
||||
|
||||
@@ -159,10 +159,11 @@ func NewAliyunClient(cfg *AliyunClientConfig) (*SAliyunClient, error) {
|
||||
return &client, nil
|
||||
}
|
||||
|
||||
func jsonRequest(client *sdk.Client, domain, apiVersion, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func jsonRequest(client *sdk.Client, domain, apiVersion, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
if debug {
|
||||
log.Debugf("request %s %s %s %s", domain, apiVersion, apiName, params)
|
||||
}
|
||||
service := strings.Split(domain, ".")[0]
|
||||
var resp jsonutils.JSONObject
|
||||
var err error
|
||||
for i := 1; i < 4; i++ {
|
||||
@@ -179,6 +180,19 @@ func jsonRequest(client *sdk.Client, domain, apiVersion, apiName string, params
|
||||
if e, ok := errors.Cause(err).(*alierr.ServerError); ok {
|
||||
code := e.ErrorCode()
|
||||
switch code {
|
||||
case "NoPermission", "Forbidden.RAM", "SubAccountNoPermission", "Forbidden":
|
||||
if updateFunc != nil {
|
||||
updateFunc(service, apiName)
|
||||
}
|
||||
return nil, errors.Wrapf(httperrors.ErrNoPermission, err.Error())
|
||||
case "InternalError":
|
||||
if apiName == "QueryAccountBalance" {
|
||||
if updateFunc != nil {
|
||||
updateFunc(service, apiName)
|
||||
}
|
||||
return nil, errors.Wrapf(httperrors.ErrNoPermission, err.Error())
|
||||
}
|
||||
return nil, err
|
||||
case "InvalidAccessKeyId.NotFound",
|
||||
"InvalidAccessKeyId",
|
||||
"NoEnabledAccessKey",
|
||||
@@ -330,7 +344,7 @@ func (self *SAliyunClient) fetchNasEndpoints() error {
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "getDefaultClient")
|
||||
}
|
||||
resp, err := jsonRequest(client, "nas.aliyuncs.com", ALIYUN_NAS_API_VERSION, "DescribeRegions", nil, self.debug)
|
||||
resp, err := jsonRequest(client, "nas.aliyuncs.com", ALIYUN_NAS_API_VERSION, "DescribeRegions", nil, self.cpcfg.UpdatePermission, self.debug)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "DescribeRegions")
|
||||
}
|
||||
@@ -370,7 +384,7 @@ func (self *SAliyunClient) fetchVpcEndpoints() error {
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "getDefaultClient")
|
||||
}
|
||||
resp, err := jsonRequest(client, "vpc.aliyuncs.com", ALIYUN_API_VERSION_VPC, "DescribeRegions", nil, self.debug)
|
||||
resp, err := jsonRequest(client, "vpc.aliyuncs.com", ALIYUN_API_VERSION_VPC, "DescribeRegions", nil, self.cpcfg.UpdatePermission, self.debug)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "DescribeRegions")
|
||||
}
|
||||
@@ -406,7 +420,7 @@ func (self *SAliyunClient) imsRequest(apiName string, params map[string]string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(cli, "ims.aliyuncs.com", ALIYUN_IMS_API_VERSION, apiName, params, self.debug)
|
||||
return jsonRequest(cli, "ims.aliyuncs.com", ALIYUN_IMS_API_VERSION, apiName, params, self.cpcfg.UpdatePermission, self.debug)
|
||||
}
|
||||
|
||||
func (self *SAliyunClient) rmRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -414,7 +428,7 @@ func (self *SAliyunClient) rmRequest(apiName string, params map[string]string) (
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(cli, "resourcemanager.aliyuncs.com", ALIYUN_RM_API_VERSION, apiName, params, self.debug)
|
||||
return jsonRequest(cli, "resourcemanager.aliyuncs.com", ALIYUN_RM_API_VERSION, apiName, params, self.cpcfg.UpdatePermission, self.debug)
|
||||
}
|
||||
|
||||
func (self *SAliyunClient) ecsRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -422,7 +436,7 @@ func (self *SAliyunClient) ecsRequest(apiName string, params map[string]string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(cli, "ecs.aliyuncs.com", ALIYUN_API_VERSION, apiName, params, self.debug)
|
||||
return jsonRequest(cli, "ecs.aliyuncs.com", ALIYUN_API_VERSION, apiName, params, self.cpcfg.UpdatePermission, self.debug)
|
||||
}
|
||||
|
||||
func (self *SAliyunClient) pvtzRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -430,7 +444,7 @@ func (self *SAliyunClient) pvtzRequest(apiName string, params map[string]string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(cli, "pvtz.aliyuncs.com", ALIYUN_PVTZ_API_VERSION, apiName, params, self.debug)
|
||||
return jsonRequest(cli, "pvtz.aliyuncs.com", ALIYUN_PVTZ_API_VERSION, apiName, params, self.cpcfg.UpdatePermission, self.debug)
|
||||
}
|
||||
|
||||
func (self *SAliyunClient) alidnsRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -438,7 +452,7 @@ func (self *SAliyunClient) alidnsRequest(apiName string, params map[string]strin
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(cli, "alidns.aliyuncs.com", ALIYUN_ALIDNS_API_VERSION, apiName, params, self.debug)
|
||||
return jsonRequest(cli, "alidns.aliyuncs.com", ALIYUN_ALIDNS_API_VERSION, apiName, params, self.cpcfg.UpdatePermission, self.debug)
|
||||
}
|
||||
|
||||
func (self *SAliyunClient) cbnRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -446,7 +460,7 @@ func (self *SAliyunClient) cbnRequest(apiName string, params map[string]string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(cli, "cbn.aliyuncs.com", ALIYUN_CBN_API_VERSION, apiName, params, self.debug)
|
||||
return jsonRequest(cli, "cbn.aliyuncs.com", ALIYUN_CBN_API_VERSION, apiName, params, self.cpcfg.UpdatePermission, self.debug)
|
||||
}
|
||||
|
||||
func (self *SAliyunClient) cdnRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -454,21 +468,19 @@ func (self *SAliyunClient) cdnRequest(apiName string, params map[string]string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(cli, "cdn.aliyuncs.com", ALIYUN_CDN_API_VERSION, apiName, params, self.debug)
|
||||
return jsonRequest(cli, "cdn.aliyuncs.com", ALIYUN_CDN_API_VERSION, apiName, params, self.cpcfg.UpdatePermission, self.debug)
|
||||
}
|
||||
|
||||
func (self *SAliyunClient) fetchRegions() error {
|
||||
body, err := self.ecsRequest("DescribeRegions", map[string]string{"AcceptLanguage": "zh-CN"})
|
||||
if err != nil {
|
||||
log.Errorf("fetchRegions fail %s", err)
|
||||
return err
|
||||
return errors.Wrapf(err, "DescribeRegions")
|
||||
}
|
||||
|
||||
regions := make([]SRegion, 0)
|
||||
err = body.Unmarshal(®ions, "Regions", "Region")
|
||||
if err != nil {
|
||||
log.Errorf("unmarshal json error %s", err)
|
||||
return err
|
||||
return errors.Wrapf(err, "resp.Unmarshal")
|
||||
}
|
||||
self.iregions = make([]cloudprovider.ICloudRegion, len(regions))
|
||||
for i := 0; i < len(regions); i += 1 {
|
||||
|
||||
@@ -29,7 +29,7 @@ func (self *SAliyunClient) businessRequest(apiName string, params map[string]str
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(cli, "business.aliyuncs.com", ALIYUN_BSS_API_VERSION, apiName, params, self.debug)
|
||||
return jsonRequest(cli, "business.aliyuncs.com", ALIYUN_BSS_API_VERSION, apiName, params, self.cpcfg.UpdatePermission, self.debug)
|
||||
}
|
||||
|
||||
type SAccountBalance struct {
|
||||
|
||||
@@ -31,7 +31,7 @@ func (r *SRegion) metricsRequest(action string, params map[string]string) (jsonu
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "r.getSdkClient")
|
||||
}
|
||||
return jsonRequest(client, "metrics.aliyuncs.com", ALIYUN_API_VERSION_METRICS, action, params, r.client.debug)
|
||||
return jsonRequest(client, "metrics.aliyuncs.com", ALIYUN_API_VERSION_METRICS, action, params, r.client.cpcfg.UpdatePermission, r.client.debug)
|
||||
}
|
||||
|
||||
type SResourceLabel struct {
|
||||
|
||||
@@ -23,5 +23,5 @@ func (self *SAliyunClient) ramRequest(apiName string, params map[string]string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(cli, "ram.aliyuncs.com", ALIYUN_RAM_API_VERSION, apiName, params, self.debug)
|
||||
return jsonRequest(cli, "ram.aliyuncs.com", ALIYUN_RAM_API_VERSION, apiName, params, self.cpcfg.UpdatePermission, self.debug)
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ func (self *SRegion) ecsRequest(apiName string, params map[string]string) (jsonu
|
||||
if len(endpoint) == 0 {
|
||||
endpoint = "ecs.aliyuncs.com"
|
||||
}
|
||||
return jsonRequest(client, endpoint, ALIYUN_API_VERSION, apiName, params, self.client.debug)
|
||||
return jsonRequest(client, endpoint, ALIYUN_API_VERSION, apiName, params, self.client.cpcfg.UpdatePermission, self.client.debug)
|
||||
}
|
||||
|
||||
func (self *SRegion) wafRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -149,7 +149,7 @@ func (self *SRegion) wafRequest(apiName string, params map[string]string) (jsonu
|
||||
return nil, cloudprovider.ErrNotSupported
|
||||
}
|
||||
endpoint := fmt.Sprintf("wafopenapi.%s.aliyuncs.com", self.RegionId)
|
||||
return jsonRequest(client, endpoint, ALIYUN_WAF_API_VERSION, apiName, params, self.client.debug)
|
||||
return jsonRequest(client, endpoint, ALIYUN_WAF_API_VERSION, apiName, params, self.client.cpcfg.UpdatePermission, self.client.debug)
|
||||
}
|
||||
|
||||
func (self *SRegion) esRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -158,7 +158,7 @@ func (self *SRegion) esRequest(apiName string, params map[string]string) (jsonut
|
||||
return nil, err
|
||||
}
|
||||
domain := fmt.Sprintf("elasticsearch.%s.aliyuncs.com", self.RegionId)
|
||||
return jsonRequest(client, domain, ALIYUN_ES_API_VERSION, apiName, params, self.client.debug)
|
||||
return jsonRequest(client, domain, ALIYUN_ES_API_VERSION, apiName, params, self.client.cpcfg.UpdatePermission, self.client.debug)
|
||||
}
|
||||
|
||||
func (self *SRegion) kafkaRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -167,7 +167,7 @@ func (self *SRegion) kafkaRequest(apiName string, params map[string]string) (jso
|
||||
return nil, err
|
||||
}
|
||||
domain := fmt.Sprintf("alikafka.%s.aliyuncs.com", self.RegionId)
|
||||
return jsonRequest(client, domain, ALIYUN_KAFKA_API_VERSION, apiName, params, self.client.debug)
|
||||
return jsonRequest(client, domain, ALIYUN_KAFKA_API_VERSION, apiName, params, self.client.cpcfg.UpdatePermission, self.client.debug)
|
||||
}
|
||||
|
||||
func (self *SRegion) rdsRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -175,7 +175,7 @@ func (self *SRegion) rdsRequest(apiName string, params map[string]string) (jsonu
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(client, "rds.aliyuncs.com", ALIYUN_RDS_API_VERSION, apiName, params, self.client.debug)
|
||||
return jsonRequest(client, "rds.aliyuncs.com", ALIYUN_RDS_API_VERSION, apiName, params, self.client.cpcfg.UpdatePermission, self.client.debug)
|
||||
}
|
||||
|
||||
func (self *SRegion) k8sRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -183,7 +183,7 @@ func (self *SRegion) k8sRequest(apiName string, params map[string]string) (jsonu
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(client, fmt.Sprintf("cs.%s.aliyuncs.com", self.RegionId), ALIYUN_K8S_API_VERSION, apiName, params, self.client.debug)
|
||||
return jsonRequest(client, fmt.Sprintf("cs.%s.aliyuncs.com", self.RegionId), ALIYUN_K8S_API_VERSION, apiName, params, self.client.cpcfg.UpdatePermission, self.client.debug)
|
||||
}
|
||||
|
||||
func (self *SRegion) mongodbRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -191,7 +191,7 @@ func (self *SRegion) mongodbRequest(apiName string, params map[string]string) (j
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(client, "mongodb.aliyuncs.com", ALIYUN_MONGO_DB_API_VERSION, apiName, params, self.client.debug)
|
||||
return jsonRequest(client, "mongodb.aliyuncs.com", ALIYUN_MONGO_DB_API_VERSION, apiName, params, self.client.cpcfg.UpdatePermission, self.client.debug)
|
||||
}
|
||||
|
||||
func (self *SRegion) vpcRequest(action string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -200,7 +200,7 @@ func (self *SRegion) vpcRequest(action string, params map[string]string) (jsonut
|
||||
return nil, err
|
||||
}
|
||||
endpoint := self.GetClient().getVpcEndpoint(self.RegionId)
|
||||
return jsonRequest(client, endpoint, ALIYUN_API_VERSION_VPC, action, params, self.client.debug)
|
||||
return jsonRequest(client, endpoint, ALIYUN_API_VERSION_VPC, action, params, self.client.cpcfg.UpdatePermission, self.client.debug)
|
||||
}
|
||||
|
||||
func (self *SRegion) nasRequest(action string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -223,7 +223,7 @@ func (self *SRegion) nasRequest(action string, params map[string]string) (jsonut
|
||||
}
|
||||
|
||||
endpint := self.GetClient().getNasEndpoint(self.RegionId)
|
||||
return jsonRequest(client, endpint, ALIYUN_NAS_API_VERSION, action, params, self.client.debug)
|
||||
return jsonRequest(client, endpint, ALIYUN_NAS_API_VERSION, action, params, self.client.cpcfg.UpdatePermission, self.client.debug)
|
||||
}
|
||||
|
||||
func (self *SRegion) kvsRequest(action string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -236,7 +236,7 @@ func (self *SRegion) kvsRequest(action string, params map[string]string) (jsonut
|
||||
params["RegionId"] = transRegionIdFromEcsRegionId(self, "redis")
|
||||
}
|
||||
|
||||
return jsonRequest(client, "r-kvstore.aliyuncs.com", ALIYUN_API_VERSION_KVS, action, params, self.client.debug)
|
||||
return jsonRequest(client, "r-kvstore.aliyuncs.com", ALIYUN_API_VERSION_KVS, action, params, self.client.cpcfg.UpdatePermission, self.client.debug)
|
||||
}
|
||||
|
||||
type LBRegion struct {
|
||||
@@ -286,7 +286,7 @@ func (self *SRegion) lbRequest(apiName string, params map[string]string) (jsonut
|
||||
}
|
||||
|
||||
func (self *SRegion) _lbRequest(client *sdk.Client, apiName string, domain string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
return jsonRequest(client, domain, ALIYUN_API_VERSION_LB, apiName, params, self.client.debug)
|
||||
return jsonRequest(client, domain, ALIYUN_API_VERSION_LB, apiName, params, self.client.cpcfg.UpdatePermission, self.client.debug)
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1240,5 +1240,5 @@ func (self *SRegion) trialRequest(apiName string, params map[string]string) (jso
|
||||
return nil, err
|
||||
}
|
||||
domain := fmt.Sprintf("actiontrail.%s.aliyuncs.com", self.RegionId)
|
||||
return jsonRequest(client, domain, ALIYUN_API_VERSION_TRIAL, apiName, params, self.client.debug)
|
||||
return jsonRequest(client, domain, ALIYUN_API_VERSION_TRIAL, apiName, params, self.client.cpcfg.UpdatePermission, self.client.debug)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func (self *SAliyunClient) stsRequest(apiName string, params map[string]string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(cli, "sts.aliyuncs.com", ALIYUN_STS_API_VERSION, apiName, params, self.debug)
|
||||
return jsonRequest(cli, "sts.aliyuncs.com", ALIYUN_STS_API_VERSION, apiName, params, self.cpcfg.UpdatePermission, self.debug)
|
||||
}
|
||||
|
||||
type SCallerIdentity struct {
|
||||
|
||||
@@ -78,7 +78,7 @@ func (r *SRegion) metricsRequest(action string, params map[string]string) (jsonu
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return monitorRequest(cli, action, params, client.debug)
|
||||
return monitorRequest(cli, action, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (r *SRegion) GetMonitorData(name string, ns string, since time.Time, until time.Time, demensions []SQcInstanceMetricDimension) ([]SDataPoint, error) {
|
||||
|
||||
+105
-81
@@ -152,152 +152,152 @@ func apiDomainByRegion(product, regionId string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func jsonRequest(client *common.Client, apiName string, params map[string]string, debug bool, retry bool) (jsonutils.JSONObject, error) {
|
||||
func jsonRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool, retry bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("cvm", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_API_VERSION, apiName, params, debug, retry)
|
||||
return _jsonRequest(client, domain, QCLOUD_API_VERSION, apiName, params, updateFunc, debug, retry)
|
||||
}
|
||||
|
||||
func tkeRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func tkeRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := "tke.tencentcloudapi.com"
|
||||
return _jsonRequest(client, domain, QCLOUD_TKE_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_TKE_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
func vpcRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func vpcRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("vpc", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
func auditRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func auditRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("cloudaudit", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_AUDIT_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_AUDIT_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
func cbsRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func cbsRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("cbs", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
func accountRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func accountRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := "account.api.qcloud.com"
|
||||
return _phpJsonRequest(client, &wssJsonResponse{}, domain, "/v2/index.php", "", apiName, params, debug)
|
||||
return _phpJsonRequest(client, &wssJsonResponse{}, domain, "/v2/index.php", "", apiName, params, updateFunc, debug)
|
||||
}
|
||||
|
||||
// es
|
||||
func esRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func esRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("es", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_ES_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_ES_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// kafka
|
||||
func kafkaRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func kafkaRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("ckafka", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_KAFKA_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_KAFKA_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// redis
|
||||
func redisRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func redisRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("redis", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_REDIS_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_REDIS_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// tdsql
|
||||
func dcdbRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func dcdbRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("dcdb", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_DCDB_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_DCDB_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// mongodb
|
||||
func mongodbRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func mongodbRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("mongodb", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_MONGODB_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_MONGODB_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// memcached
|
||||
func memcachedRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func memcachedRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("memcached", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_MEMCACHED_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_MEMCACHED_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// loadbalancer服务 api 3.0
|
||||
func clbRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func clbRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("clb", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_CLB_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_CLB_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// loadbalancer服务 api 2017
|
||||
func lbRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func lbRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := "lb.api.qcloud.com"
|
||||
return _phpJsonRequest(client, &lbJsonResponse{}, domain, "/v2/index.php", "", apiName, params, debug)
|
||||
return _phpJsonRequest(client, &lbJsonResponse{}, domain, "/v2/index.php", "", apiName, params, updateFunc, debug)
|
||||
}
|
||||
|
||||
// cdb
|
||||
func cdbRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func cdbRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("cdb", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_CDB_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_CDB_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// mariadb
|
||||
func mariadbRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func mariadbRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("mariadb", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_MARIADB_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_MARIADB_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// postgres
|
||||
func postgresRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func postgresRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("postgres", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_POSTGRES_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_POSTGRES_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// sqlserver
|
||||
func sqlserverRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func sqlserverRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := apiDomain("sqlserver", params)
|
||||
return _jsonRequest(client, domain, QCLOUD_SQLSERVER_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_SQLSERVER_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// deprecated: ssl 证书服务
|
||||
func wssRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func wssRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := "wss.api.qcloud.com"
|
||||
return _phpJsonRequest(client, &wssJsonResponse{}, domain, "/v2/index.php", "", apiName, params, debug)
|
||||
return _phpJsonRequest(client, &wssJsonResponse{}, domain, "/v2/index.php", "", apiName, params, updateFunc, debug)
|
||||
}
|
||||
|
||||
// ssl 证书服务
|
||||
func sslRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func sslRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := "ssl.tencentcloudapi.com"
|
||||
return _jsonRequest(client, domain, QCLOUD_SSL_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_SSL_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// dnspod 解析服务
|
||||
func cnsRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func cnsRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := "cns.api.qcloud.com"
|
||||
return _phpJsonRequest(client, &wssJsonResponse{}, domain, "/v2/index.php", "", apiName, params, debug)
|
||||
return _phpJsonRequest(client, &wssJsonResponse{}, domain, "/v2/index.php", "", apiName, params, updateFunc, debug)
|
||||
}
|
||||
|
||||
// 2017版API
|
||||
func vpc2017Request(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func vpc2017Request(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := "vpc.api.qcloud.com"
|
||||
return _phpJsonRequest(client, &vpc2017JsonResponse{}, domain, "/v2/index.php", "", apiName, params, debug)
|
||||
return _phpJsonRequest(client, &vpc2017JsonResponse{}, domain, "/v2/index.php", "", apiName, params, updateFunc, debug)
|
||||
}
|
||||
|
||||
func billingRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func billingRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := "billing.tencentcloudapi.com"
|
||||
return _jsonRequest(client, domain, QCLOUD_BILLING_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_BILLING_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
func camRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func camRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := "cam.tencentcloudapi.com"
|
||||
return _jsonRequest(client, domain, QCLOUD_CAM_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_CAM_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
func monitorRequest(client *common.Client, apiName string, params map[string]string,
|
||||
func monitorRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string),
|
||||
debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := "monitor.tencentcloudapi.com"
|
||||
return _jsonRequest(client, domain, QCLOUD_API_VERSION_METRICS, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_API_VERSION_METRICS, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
func cdnRequest(client *common.Client, apiName string, params map[string]string,
|
||||
func cdnRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string),
|
||||
debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := "cdn.tencentcloudapi.com"
|
||||
return _jsonRequest(client, domain, QCLOUD_CDN_API_VERSION, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_CDN_API_VERSION, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
// ============phpJsonRequest============
|
||||
@@ -441,7 +441,7 @@ func (r *QcloudResponse) GetResponse() *interface{} {
|
||||
return r.Response
|
||||
}
|
||||
|
||||
func _jsonRequest(client *common.Client, domain string, version string, apiName string, params map[string]string, debug bool, retry bool) (jsonutils.JSONObject, error) {
|
||||
func _jsonRequest(client *common.Client, domain string, version string, apiName string, params map[string]string, updateFun func(string, string), debug bool, retry bool) (jsonutils.JSONObject, error) {
|
||||
req := &tchttp.BaseRequest{}
|
||||
if region, ok := params["Region"]; ok {
|
||||
client = client.Init(region)
|
||||
@@ -463,12 +463,19 @@ func _jsonRequest(client *common.Client, domain string, version string, apiName
|
||||
resp := &QcloudResponse{
|
||||
BaseResponse: &tchttp.BaseResponse{},
|
||||
}
|
||||
return _baseJsonRequest(client, req, resp, debug, retry)
|
||||
ret, err := _baseJsonRequest(client, req, resp, debug, retry)
|
||||
if err != nil {
|
||||
if errors.Cause(err) == httperrors.ErrNoPermission && updateFun != nil {
|
||||
updateFun(service, apiName)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// 老版本腾讯云api。 适用于类似 https://cvm.api.qcloud.com/v2/index.php 这样的带/v2/index.php路径的接口
|
||||
// todo: 添加自定义response参数
|
||||
func _phpJsonRequest(client *common.Client, resp qcloudResponse, domain string, path string, version string, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func _phpJsonRequest(client *common.Client, resp qcloudResponse, domain string, path string, version string, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
req := &phpJsonRequest{Path: path}
|
||||
if region, ok := params["Region"]; ok {
|
||||
client = client.Init(region)
|
||||
@@ -487,7 +494,14 @@ func _phpJsonRequest(client *common.Client, resp qcloudResponse, domain string,
|
||||
req.GetParams()[k] = v
|
||||
}
|
||||
|
||||
return _baseJsonRequest(client, req, resp, debug, true)
|
||||
ret, err := _baseJsonRequest(client, req, resp, debug, true)
|
||||
if err != nil {
|
||||
if errors.Cause(err) == httperrors.ErrNoPermission && updateFunc != nil {
|
||||
updateFunc(service, apiName)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func _baseJsonRequest(client *common.Client, req tchttp.Request, resp qcloudResponse, debug bool, retry bool) (jsonutils.JSONObject, error) {
|
||||
@@ -504,6 +518,16 @@ func _baseJsonRequest(client *common.Client, req tchttp.Request, resp qcloudResp
|
||||
needRetry := false
|
||||
e, ok := err.(*sdkerrors.TencentCloudSDKError)
|
||||
if ok {
|
||||
if strings.HasPrefix(e.Code, "UnauthorizedOperation.") ||
|
||||
strings.HasPrefix(e.Code, "AuthFailure.") ||
|
||||
utils.IsInStringArray(e.Code, []string{
|
||||
"SecretidNotAuthAccessResource",
|
||||
"UnauthorizedOperation",
|
||||
"InvalidParameter.PermissionDenied",
|
||||
"AuthFailure",
|
||||
}) {
|
||||
return nil, errors.Wrapf(httperrors.ErrNoPermission, err.Error())
|
||||
}
|
||||
if utils.IsInStringArray(e.Code, []string{
|
||||
"AuthFailure.SecretIdNotFound",
|
||||
"AuthFailure.SignatureFailure",
|
||||
@@ -611,7 +635,7 @@ func (client *SQcloudClient) tkeRequest(apiName string, params map[string]string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return tkeRequest(cli, apiName, params, client.debug)
|
||||
return tkeRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) vpcRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -619,7 +643,7 @@ func (client *SQcloudClient) vpcRequest(apiName string, params map[string]string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return vpcRequest(cli, apiName, params, client.debug)
|
||||
return vpcRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) auditRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -627,7 +651,7 @@ func (client *SQcloudClient) auditRequest(apiName string, params map[string]stri
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return auditRequest(cli, apiName, params, client.debug)
|
||||
return auditRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) cbsRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -635,7 +659,7 @@ func (client *SQcloudClient) cbsRequest(apiName string, params map[string]string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cbsRequest(cli, apiName, params, client.debug)
|
||||
return cbsRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) accountRequestRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -643,7 +667,7 @@ func (client *SQcloudClient) accountRequestRequest(apiName string, params map[st
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return accountRequest(cli, apiName, params, client.debug)
|
||||
return accountRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) clbRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -651,7 +675,7 @@ func (client *SQcloudClient) clbRequest(apiName string, params map[string]string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return clbRequest(cli, apiName, params, client.debug)
|
||||
return clbRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) lbRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -659,7 +683,7 @@ func (client *SQcloudClient) lbRequest(apiName string, params map[string]string)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return lbRequest(cli, apiName, params, client.debug)
|
||||
return lbRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) cdbRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -667,7 +691,7 @@ func (client *SQcloudClient) cdbRequest(apiName string, params map[string]string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cdbRequest(cli, apiName, params, client.debug)
|
||||
return cdbRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) esRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -676,7 +700,7 @@ func (client *SQcloudClient) esRequest(apiName string, params map[string]string)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return esRequest(cli, apiName, params, client.debug)
|
||||
return esRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) kafkaRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -685,7 +709,7 @@ func (client *SQcloudClient) kafkaRequest(apiName string, params map[string]stri
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return kafkaRequest(cli, apiName, params, client.debug)
|
||||
return kafkaRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) redisRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -694,7 +718,7 @@ func (client *SQcloudClient) redisRequest(apiName string, params map[string]stri
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return redisRequest(cli, apiName, params, client.debug)
|
||||
return redisRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) dcdbRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -703,7 +727,7 @@ func (client *SQcloudClient) dcdbRequest(apiName string, params map[string]strin
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dcdbRequest(cli, apiName, params, client.debug)
|
||||
return dcdbRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) mongodbRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -712,7 +736,7 @@ func (client *SQcloudClient) mongodbRequest(apiName string, params map[string]st
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return mongodbRequest(cli, apiName, params, client.debug)
|
||||
return mongodbRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) memcachedRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -721,7 +745,7 @@ func (client *SQcloudClient) memcachedRequest(apiName string, params map[string]
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return memcachedRequest(cli, apiName, params, client.debug)
|
||||
return memcachedRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) mariadbRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -729,7 +753,7 @@ func (client *SQcloudClient) mariadbRequest(apiName string, params map[string]st
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mariadbRequest(cli, apiName, params, client.debug)
|
||||
return mariadbRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) postgresRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -737,7 +761,7 @@ func (client *SQcloudClient) postgresRequest(apiName string, params map[string]s
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return postgresRequest(cli, apiName, params, client.debug)
|
||||
return postgresRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) sqlserverRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -745,7 +769,7 @@ func (client *SQcloudClient) sqlserverRequest(apiName string, params map[string]
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return sqlserverRequest(cli, apiName, params, client.debug)
|
||||
return sqlserverRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
// deprecated
|
||||
@@ -754,7 +778,7 @@ func (client *SQcloudClient) wssRequest(apiName string, params map[string]string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return wssRequest(cli, apiName, params, client.debug)
|
||||
return wssRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) sslRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -762,7 +786,7 @@ func (client *SQcloudClient) sslRequest(apiName string, params map[string]string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return sslRequest(cli, apiName, params, client.debug)
|
||||
return sslRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) cnsRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -770,7 +794,7 @@ func (client *SQcloudClient) cnsRequest(apiName string, params map[string]string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cnsRequest(cli, apiName, params, client.debug)
|
||||
return cnsRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) vpc2017Request(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -778,7 +802,7 @@ func (client *SQcloudClient) vpc2017Request(apiName string, params map[string]st
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return vpc2017Request(cli, apiName, params, client.debug)
|
||||
return vpc2017Request(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) billingRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -786,7 +810,7 @@ func (client *SQcloudClient) billingRequest(apiName string, params map[string]st
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return billingRequest(cli, apiName, params, client.debug)
|
||||
return billingRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) camRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -794,7 +818,7 @@ func (client *SQcloudClient) camRequest(apiName string, params map[string]string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return camRequest(cli, apiName, params, client.debug)
|
||||
return camRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) cdnRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -802,7 +826,7 @@ func (client *SQcloudClient) cdnRequest(apiName string, params map[string]string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cdnRequest(cli, apiName, params, client.debug)
|
||||
return cdnRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) jsonRequest(apiName string, params map[string]string, retry bool) (jsonutils.JSONObject, error) {
|
||||
@@ -810,7 +834,7 @@ func (client *SQcloudClient) jsonRequest(apiName string, params map[string]strin
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonRequest(cli, apiName, params, client.debug, retry)
|
||||
return jsonRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug, retry)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) fetchRegions() error {
|
||||
|
||||
@@ -29,9 +29,9 @@ const (
|
||||
QCLOUD_API_VERSION_TAGS = "2018-08-13"
|
||||
)
|
||||
|
||||
func tagRequest(client *common.Client, apiName string, params map[string]string, debug bool) (jsonutils.JSONObject, error) {
|
||||
func tagRequest(client *common.Client, apiName string, params map[string]string, updateFunc func(string, string), debug bool) (jsonutils.JSONObject, error) {
|
||||
domain := "tag.tencentcloudapi.com"
|
||||
return _jsonRequest(client, domain, QCLOUD_API_VERSION_TAGS, apiName, params, debug, true)
|
||||
return _jsonRequest(client, domain, QCLOUD_API_VERSION_TAGS, apiName, params, updateFunc, debug, true)
|
||||
}
|
||||
|
||||
func (client *SQcloudClient) tagRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
@@ -39,7 +39,7 @@ func (client *SQcloudClient) tagRequest(apiName string, params map[string]string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return tagRequest(cli, apiName, params, client.debug)
|
||||
return tagRequest(cli, apiName, params, client.cpcfg.UpdatePermission, client.debug)
|
||||
}
|
||||
|
||||
type SFetchTagRow struct {
|
||||
|
||||
Reference in New Issue
Block a user