-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvolumes_default.go
64 lines (52 loc) · 2.46 KB
/
volumes_default.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
// Code generated by go generate; DO NOT EDIT.
package brightbox
import "context"
import "path"
const (
// volumeAPIPath returns the relative URL path to the Volume endpoint
volumeAPIPath = "volumes"
)
// Volumes returns the collection view for Volume
func (c *Client) Volumes(ctx context.Context) ([]Volume, error) {
return apiGetCollection[[]Volume](ctx, c, volumeAPIPath)
}
// Volume retrieves a detailed view of one resource
func (c *Client) Volume(ctx context.Context, identifier string) (*Volume, error) {
return apiGet[Volume](ctx, c, path.Join(volumeAPIPath, identifier))
}
// CreateVolume creates a new resource from the supplied option map.
//
// It takes an instance of VolumeOptions. Not all attributes can be
// specified at create time (such as ID, which is allocated for you).
func (c *Client) CreateVolume(ctx context.Context, newVolume VolumeOptions) (*Volume, error) {
return apiPost[Volume](ctx, c, volumeAPIPath, newVolume)
}
// UpdateVolume updates an existing resources's attributes. Not all
// attributes can be changed (such as ID).
//
// It takes an instance of VolumeOptions. Specify the resource you
// want to update using the ID field.
func (c *Client) UpdateVolume(ctx context.Context, updateVolume VolumeOptions) (*Volume, error) {
return apiPut[Volume](ctx, c, path.Join(volumeAPIPath, updateVolume.ID), updateVolume)
}
// DestroyVolume destroys an existing resource.
func (c *Client) DestroyVolume(ctx context.Context, identifier string) (*Volume, error) {
return apiDelete[Volume](ctx, c, path.Join(volumeAPIPath, identifier))
}
// LockVolume locks a resource against destroy requests
func (c *Client) LockVolume(ctx context.Context, identifier string) (*Volume, error) {
return apiPut[Volume](ctx, c, path.Join(volumeAPIPath, identifier, "lock_resource"), nil)
}
// UnlockVolume unlocks a resource, re-enabling destroy requests
func (c *Client) UnlockVolume(ctx context.Context, identifier string) (*Volume, error) {
return apiPut[Volume](ctx, c, path.Join(volumeAPIPath, identifier, "unlock_resource"), nil)
}
// CreatedAt implements the CreateDated interface for Volume
func (s Volume) CreatedAtUnix() int64 {
return s.CreatedAt.Unix()
}
// ResizeVolume issues a request to change the server type of a server
// changing the amount of cpu and ram it has.
func (c *Client) ResizeVolume(ctx context.Context, identifier string, newSize VolumeNewSize) (*Volume, error) {
return apiPost[Volume](ctx, c, path.Join(volumeAPIPath, identifier, "resize"), newSize)
}