Closed feeops closed 10 months ago
package main import ( "fmt" "github.com/aliyun/alibaba-cloud-sdk-go/sdk" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" bssopenapi "github.com/aliyun/alibaba-cloud-sdk-go/services/bssopenapi" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" ) func main() { config := sdk.NewConfig() credential := credentials.NewAccessKeyCredential("<your-access-key-id>", "<your-access-key-secret>") /* use STS Token credential := credentials.NewStsTokenCredential("<your-access-key-id>", "<your-access-key-secret>", "<your-sts-token>") */ client, err := bssopenapi.NewClientWithOptions("cn-hangzhou", config, credential) if err != nil { panic(err) } request := bssopenapi.CreateDescribeInstanceBillRequest() request.Scheme = "https" request.IsHideZeroCharge = requests.NewBoolean(true) request.MaxResults = requests.NewInteger(300) response, err := client.DescribeInstanceBill(request) if err != nil { fmt.Print(err.Error()) } fmt.Printf("response is %#v\n", response) for _, item := range response.Data.Items { fmt.Println(item.Type) } }
需要调实例账单信息,结果item是节省计划的结构体
参考文档 https://help.aliyun.com/document_detail/209402.html
升级版golangSDK了解一下呢 https://next.api.aliyun.com/api/BssOpenApi/2017-12-14/QueryAccountBalance?lang=GO&sdkStyle=dara
需要调实例账单信息,结果item是节省计划的结构体
参考文档 https://help.aliyun.com/document_detail/209402.html