-
Notifications
You must be signed in to change notification settings - Fork 2
/
database_servers_default.go
76 lines (62 loc) · 3.57 KB
/
database_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
65
66
67
68
69
70
71
72
73
74
75
76
// Code generated by go generate; DO NOT EDIT.
package brightbox
import "context"
import "path"
const (
// databaseserverAPIPath returns the relative URL path to the DatabaseServer endpoint
databaseserverAPIPath = "database_servers"
)
// DatabaseServers returns the collection view for DatabaseServer
func (c *Client) DatabaseServers(ctx context.Context) ([]DatabaseServer, error) {
return apiGetCollection[[]DatabaseServer](ctx, c, databaseserverAPIPath)
}
// DatabaseServer retrieves a detailed view of one resource
func (c *Client) DatabaseServer(ctx context.Context, identifier string) (*DatabaseServer, error) {
return apiGet[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier))
}
// CreateDatabaseServer creates a new resource from the supplied option map.
//
// It takes an instance of DatabaseServerOptions. Not all attributes can be
// specified at create time (such as ID, which is allocated for you).
func (c *Client) CreateDatabaseServer(ctx context.Context, newDatabaseServer DatabaseServerOptions) (*DatabaseServer, error) {
return apiPost[DatabaseServer](ctx, c, databaseserverAPIPath, newDatabaseServer)
}
// UpdateDatabaseServer updates an existing resources's attributes. Not all
// attributes can be changed (such as ID).
//
// It takes an instance of DatabaseServerOptions. Specify the resource you
// want to update using the ID field.
func (c *Client) UpdateDatabaseServer(ctx context.Context, updateDatabaseServer DatabaseServerOptions) (*DatabaseServer, error) {
return apiPut[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, updateDatabaseServer.ID), updateDatabaseServer)
}
// DestroyDatabaseServer destroys an existing resource.
func (c *Client) DestroyDatabaseServer(ctx context.Context, identifier string) (*DatabaseServer, error) {
return apiDelete[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier))
}
// LockDatabaseServer locks a resource against destroy requests
func (c *Client) LockDatabaseServer(ctx context.Context, identifier string) (*DatabaseServer, error) {
return apiPut[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier, "lock_resource"), nil)
}
// UnlockDatabaseServer unlocks a resource, re-enabling destroy requests
func (c *Client) UnlockDatabaseServer(ctx context.Context, identifier string) (*DatabaseServer, error) {
return apiPut[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier, "unlock_resource"), nil)
}
// CreatedAt implements the CreateDated interface for DatabaseServer
func (s DatabaseServer) CreatedAtUnix() int64 {
return s.CreatedAt.Unix()
}
// ResetDatabaseServerPassword resets the password in DatabaseServer, returning it
// in the returned resource. This is the only time the new password is
// available in plaintext.
func (c *Client) ResetDatabaseServerPassword(ctx context.Context, identifier string) (*DatabaseServer, error) {
return apiPost[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier, "reset_password"), nil)
}
// ResizeDatabaseServer issues a request to change the server type of a server
// changing the amount of cpu and ram it has.
func (c *Client) ResizeDatabaseServer(ctx context.Context, identifier string, newSize DatabaseServerNewSize) (*DatabaseServer, error) {
return apiPost[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier, "resize"), newSize)
}
// ResetDatabaseServer issues a "reset" instruction to a DatabaseServer
func (c *Client) ResetDatabaseServer(ctx context.Context, identifier string) (*DatabaseServer, error) {
return apiPost[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier, "reset"), nil)
}