-
Notifications
You must be signed in to change notification settings - Fork 2
/
payperuseresource.go
67 lines (57 loc) · 1.62 KB
/
payperuseresource.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"encoding/json"
"fmt"
"github.com/Huawei/gophercloud"
"github.com/Huawei/gophercloud/functiontest/common"
"github.com/Huawei/gophercloud/openstack"
"github.com/Huawei/gophercloud/openstack/bssintl/v1/payperuseresource"
)
func main() {
fmt.Println("payperuseresource start...")
//打开debug日志
gophercloud.EnableDebug = true
provider, err := common.AuthToken()
//provider, err := common.AuthAKSK()
if err != nil {
fmt.Println("get provider client failed")
fmt.Println(err.Error())
return
}
fmt.Println("auth success!")
// 初始化服务的client
sc, err := openstack.NewBSSIntlV1(provider, gophercloud.EndpointOpts{})
if err != nil {
fmt.Println("get bss client failed")
fmt.Println(err.Error())
return
}
TestQueryCustomerResource(sc)
fmt.Println("payperuseresource end...")
}
func TestQueryCustomerResource(client *gophercloud.ServiceClient) {
opts := payperuseresource.QueryCustomerResourceOpts{
CustomerResourceId: "",
CustomerId: "123",
RegionCode: "",
CloudServiceTypeCode: "0",
ResourceIds: nil,
ResourceName: "",
StartTimeBegin: "",
StartTimeEnd: "",
PageNo: 0,
PageSize: 0,
}
detailRsp,err := payperuseresource.QueryCustomerResource(client, opts).Extract()
if err != nil {
fmt.Println("err:", err)
if ue, ok := err.(*gophercloud.UnifiedError); ok {
fmt.Println("ErrCode:", ue.ErrorCode())
fmt.Println("Message:", ue.Message())
}
return
}
bytes, _ := json.MarshalIndent(detailRsp, "", " ")
fmt.Println(string(bytes))
fmt.Println("TestQueryResources success")
}