/
requests.go
66 lines (50 loc) · 2 KB
/
requests.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
package payperuseresource
import "github.com/dynuc/gophercloud"
type QueryCustomerResourceOpts struct {
//Customer resource ID.
CustomerResourceId string `json:"customerResourceId,omitempty"`
//Customer ID.
CustomerId string `json:"customerId" required:"true"`
//Cloud service region code
RegionCode string `json:"regionCode,omitempty"`
//Cloud service type code
CloudServiceTypeCode string `json:"cloudServiceTypeCode,omitempty"`
//Resource type code
ResourceTypeCode string `json:"resourceTypeCode,omitempty"`
//Queries resource IDs in batches
ResourceIds []string `json:"resourceIds,omitempty"`
//Resource instance name
ResourceName string `json:"resourceName,omitempty"`
//Start time of the validity period
StartTimeBegin string `json:"startTimeBegin,omitempty"`
//End time of the validity period
StartTimeEnd string `json:"startTimeEnd,omitempty"`
//Current page
PageNo int `json:"pageNo,omitempty"`
//Number of records displayed on each page
PageSize int `json:"pageSize,omitempty"`
}
type QueryCustomerResourceOptsBuilder interface {
ToQueryCustomerResourceMap() (map[string]interface{}, error)
}
func (opts QueryCustomerResourceOpts) ToQueryCustomerResourceMap() (map[string]interface{}, error) {
return gophercloud.BuildRequestBody(opts, "")
}
/**
* A customer can query its pay-per-use resources on the partner sales platform. The on-demand resource data has a latency, and the latency for each cloud service data varies. The data obtained using this API is for reference only.
* This API can be invoked using the partner AK/SK or token only.
*/
func QueryCustomerResource(client *gophercloud.ServiceClient, opts QueryCustomerResourceOptsBuilder) (r QueryCustomerResourceResult) {
domainID := client.ProviderClient.DomainID
if opts != nil {
body, err := opts.ToQueryCustomerResourceMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Post(getQueryCustomerResourceURL(client, domainID), body, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
}
return
}