-
Notifications
You must be signed in to change notification settings - Fork 91
/
service.go
53 lines (48 loc) · 1.46 KB
/
service.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
package cos
import (
"context"
"encoding/xml"
"net/http"
)
// Service 相关 API
type ServiceService service
// ServiceGetResult is the result of Get Service
type ServiceGetResult struct {
XMLName xml.Name `xml:"ListAllMyBucketsResult"`
Owner *Owner `xml:"Owner"`
Buckets []Bucket `xml:"Buckets>Bucket,omitempty"`
Marker string `xml:"Marker"`
NextMarker string `xml:"NextMarker"`
IsTruncated bool `xml:"IsTruncated"`
}
type ServiceGetOptions struct {
TagKey string `url:"tagkey,omitempty"`
TagValue string `url:"tagvalue,omitempty"`
MaxKeys int64 `url:"max-keys,omitempty"`
Marker string `url:"marker,omitempty"`
Range string `url:"range,omitempty"`
CreateTime int64 `url:"create-time,omitempty"`
Region string `url:"region,omitempty"`
}
// Get Service 接口实现获取该用户下所有Bucket列表。
//
// 该API接口需要使用Authorization签名认证,
// 且只能获取签名中AccessID所属账户的Bucket列表。
//
// https://www.qcloud.com/document/product/436/8291
func (s *ServiceService) Get(ctx context.Context, opt ...*ServiceGetOptions) (*ServiceGetResult, *Response, error) {
var sopt *ServiceGetOptions
if len(opt) > 0 {
sopt = opt[0]
}
var res ServiceGetResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.ServiceURL,
uri: "/",
method: http.MethodGet,
optQuery: sopt,
result: &res,
}
resp, err := s.client.doRetry(ctx, &sendOpt)
return &res, resp, err
}