aliyun / alibabacloud-go-sdk

https://next.api.aliyun.com/
31 stars 8 forks source link

r-kvstore DescribeAvailableResourceRequest lack RegionId params #2

Closed zeromake closed 3 years ago

zeromake commented 3 years ago

go.mod

require (
    github.com/alibabacloud-go/darabonba-openapi v0.1.4
    github.com/alibabacloud-go/r-kvstore-20150101 v1.0.1
    github.com/alibabacloud-go/tea v1.1.15
)

main.go

package main

import (
    "os"

    openapi "github.com/alibabacloud-go/darabonba-openapi/client"
    r_kvstore20150101 "github.com/alibabacloud-go/r-kvstore-20150101/client"
    "github.com/alibabacloud-go/tea/tea"
)

/**
 * 使用AK&SK初始化账号Client
 * @param accessKeyId
 * @param accessKeySecret
 * @return Client
 * @throws Exception
 */
func CreateClient(accessKeyId *string, accessKeySecret *string) (_result *r_kvstore20150101.Client, _err error) {
    config := &openapi.Config{
        // 您的AccessKey ID
        AccessKeyId: accessKeyId,
        // 您的AccessKey Secret
        AccessKeySecret: accessKeySecret,
        RegionId:        tea.String("cn-hangzhou"),
    }
    // 访问的域名
    config.Endpoint = tea.String("r-kvstore.aliyuncs.com")
    _result = &r_kvstore20150101.Client{}
    _result, _err = r_kvstore20150101.NewClient(config)
    return _result, _err
}

func _main(args []*string) (_err error) {
    client, _err := CreateClient(tea.String(""), tea.String(""))
    if _err != nil {
        return _err
    }

    describeAvailableResourceRequest := &r_kvstore20150101.DescribeAvailableResourceRequest{}
    _, _err = client.DescribeAvailableResource(describeAvailableResourceRequest)
    if _err != nil {
        return _err
    }
    return _err
}

func main() {
    err := _main(tea.StringSlice(os.Args[1:]))
    if err != nil {
        panic(err)
    }
}

go run main.go

panic: SDKError:
   Code: MissingParameter
   Message: code: 400, The input parameter "RegionId" that is mandatory for processing this request is not supplied. request id: E47BC800-760A-42AE-B991-668FA1556853
   Data: {"Code":"MissingParameter","HostId":"r-kvstore.aliyuncs.com","Message":"The input parameter \"RegionId\" that is mandatory for processing this request is not supplied.","Recommend":"https://error-center.aliyun.com/status/search?Keyword=MissingParameter\u0026source=PopGw","RequestId":"E47BC800-760A-42AE-B991-668FA1556853"}

modify client.go DescribeAvailableResourceRequest struct

type DescribeAvailableResourceRequest struct {
    RegionId             *string `json:"RegionId,omitempty" xml:"RegionId,omitempty"`
    SecurityToken        *string `json:"SecurityToken,omitempty" xml:"SecurityToken,omitempty"`
    OwnerId              *int64  `json:"OwnerId,omitempty" xml:"OwnerId,omitempty"`
    ResourceOwnerAccount *string `json:"ResourceOwnerAccount,omitempty" xml:"ResourceOwnerAccount,omitempty"`
    ResourceOwnerId      *int64  `json:"ResourceOwnerId,omitempty" xml:"ResourceOwnerId,omitempty"`
    OwnerAccount         *string `json:"OwnerAccount,omitempty" xml:"OwnerAccount,omitempty"`
    ZoneId               *string `json:"ZoneId,omitempty" xml:"ZoneId,omitempty"`
    InstanceChargeType   *string `json:"InstanceChargeType,omitempty" xml:"InstanceChargeType,omitempty"`
    OrderType            *string `json:"OrderType,omitempty" xml:"OrderType,omitempty"`
    Level                *string `json:"Level,omitempty" xml:"Level,omitempty"`
    Engine               *string `json:"Engine,omitempty" xml:"Engine,omitempty"`
    ResourceGroupId      *string `json:"ResourceGroupId,omitempty" xml:"ResourceGroupId,omitempty"`
    InstanceId           *string `json:"InstanceId,omitempty" xml:"InstanceId,omitempty"`
    AcceptLanguage       *string `json:"AcceptLanguage,omitempty" xml:"AcceptLanguage,omitempty"`
}
AxiosLeo commented 3 years ago

The RegionId parameter is a system-level parameter used for host addressing operations, so It will not be added to the Request class. Because the code is automatically generated, so it cannot be changed manually, otherwise the changes will be overwritten in the subsequent generation. I need to contact the API developer to change the level of the RegionID to fix this issue. Please wait later :)

zeromake commented 3 years ago

@AxiosCros Yes, I see the corresponding build configuration by main.tea

AxiosLeo commented 3 years ago

@zeromake This issue has been fixed in this COMMIT

If there are no other problems, please close this issue.