-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusage.go
63 lines (59 loc) · 1.84 KB
/
usage.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
package rgwadmin
import (
"encoding/json"
)
//Usage struct
type Usage struct {
Entries []struct {
User string `json:"user"`
Buckets []struct {
Bucket string `json:"bucket"`
Time string `json:"time"`
Epoch uint64 `json:"epoch"`
Owner string `json:"owner"`
Categories []struct {
Category string `json:"category"`
BytesSent uint64 `json:"bytes_sent"`
BytesReceived uint64 `json:"bytes_received"`
Ops uint64 `json:"ops"`
SuccessfulOps uint64 `json:"successful_ops"`
} `json:"categories"`
} `json:"buckets"`
} `json:"entries"`
Summary []struct {
User string `json:"user"`
Categories []struct {
Category string `json:"category"`
BytesSent uint64 `json:"bytes_sent"`
BytesReceived uint64 `json:"bytes_received"`
Ops uint64 `json:"ops"`
SuccessfulOps uint64 `json:"successful_ops"`
} `json:"categories"`
Total struct {
BytesSent uint64 `json:"bytes_sent"`
BytesReceived uint64 `json:"bytes_received"`
Ops uint64 `json:"ops"`
SuccessfulOps uint64 `json:"successful_ops"`
} `json:"total"`
} `json:"summary"`
Start string `url:"start"` //Example: 2012-09-25 16:00:00
End string `url:"end"`
ShowEntries *bool `url:"show-entries"`
ShowSummary *bool `url:"show-summary"`
RemoveAll *bool `url:"remove-all"` //true
}
//GetUsage - http://docs.ceph.com/docs/mimic/radosgw/adminops/#get-usage
func (api *API) GetUsage(usage Usage) (*Usage, error) {
body, err := api.Query("GET", "/usage", GetValues(usage))
if err != nil {
return nil, err
}
ref := &Usage{}
err = json.Unmarshal(body, &ref)
return ref, err
}
//TrimUsage - http://docs.ceph.com/docs/mimic/radosgw/adminops/#trim-usage
func (api *API) TrimUsage(usage Usage) error {
_, err := api.Query("DELETE", "/usage", GetValues(usage))
return err
}