-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathservers_default.go
64 lines (52 loc) · 2.46 KB
/
servers_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 (
// serverAPIPath returns the relative URL path to the Server endpoint
serverAPIPath = "servers"
)
// Servers returns the collection view for Server
func (c *Client) Servers(ctx context.Context) ([]Server, error) {
return apiGetCollection[[]Server](ctx, c, serverAPIPath)
}
// Server retrieves a detailed view of one resource
func (c *Client) Server(ctx context.Context, identifier string) (*Server, error) {
return apiGet[Server](ctx, c, path.Join(serverAPIPath, identifier))
}
// CreateServer creates a new resource from the supplied option map.
//
// It takes an instance of ServerOptions. Not all attributes can be
// specified at create time (such as ID, which is allocated for you).
func (c *Client) CreateServer(ctx context.Context, newServer ServerOptions) (*Server, error) {
return apiPost[Server](ctx, c, serverAPIPath, newServer)
}
// UpdateServer updates an existing resources's attributes. Not all
// attributes can be changed (such as ID).
//
// It takes an instance of ServerOptions. Specify the resource you
// want to update using the ID field.
func (c *Client) UpdateServer(ctx context.Context, updateServer ServerOptions) (*Server, error) {
return apiPut[Server](ctx, c, path.Join(serverAPIPath, updateServer.ID), updateServer)
}
// DestroyServer destroys an existing resource.
func (c *Client) DestroyServer(ctx context.Context, identifier string) (*Server, error) {
return apiDelete[Server](ctx, c, path.Join(serverAPIPath, identifier))
}
// LockServer locks a resource against destroy requests
func (c *Client) LockServer(ctx context.Context, identifier string) (*Server, error) {
return apiPut[Server](ctx, c, path.Join(serverAPIPath, identifier, "lock_resource"), nil)
}
// UnlockServer unlocks a resource, re-enabling destroy requests
func (c *Client) UnlockServer(ctx context.Context, identifier string) (*Server, error) {
return apiPut[Server](ctx, c, path.Join(serverAPIPath, identifier, "unlock_resource"), nil)
}
// CreatedAt implements the CreateDated interface for Server
func (s Server) CreatedAtUnix() int64 {
return s.CreatedAt.Unix()
}
// ResizeServer issues a request to change the server type of a server
// changing the amount of cpu and ram it has.
func (c *Client) ResizeServer(ctx context.Context, identifier string, newSize ServerNewSize) (*Server, error) {
return apiPost[Server](ctx, c, path.Join(serverAPIPath, identifier, "resize"), newSize)
}