forked from linode/linodego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject_storage.go
47 lines (37 loc) · 1.02 KB
/
object_storage.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
package linodego
import (
"context"
"fmt"
)
// ObjectStorageTransfer is an object matching the response of object-storage/transfer
type ObjectStorageTransfer struct {
AmmountUsed int `json:"used"`
}
// CancelObjectStorage cancels and removes all object storage from the Account
func (c *Client) CancelObjectStorage(ctx context.Context) error {
e, err := c.ObjectStorage.Endpoint()
if err != nil {
return err
}
req := c.R(ctx)
e = fmt.Sprintf("%s/cancel", e)
_, err = coupleAPIErrors(req.Post(e))
if err != nil {
return err
}
return nil
}
// GetObjectStorageTransfer returns the amount of outbound data transferred used by the Account
func (c *Client) GetObjectStorageTransfer(ctx context.Context) (*ObjectStorageTransfer, error) {
e, err := c.ObjectStorage.Endpoint()
if err != nil {
return nil, err
}
req := c.R(ctx)
e = fmt.Sprintf("%s/transfer", e)
r, err := coupleAPIErrors(req.SetResult(&ObjectStorageTransfer{}).Get(e))
if err != nil {
return nil, err
}
return r.Result().(*ObjectStorageTransfer), nil
}