-
Notifications
You must be signed in to change notification settings - Fork 14
/
serverdisks.go
94 lines (83 loc) · 2.89 KB
/
serverdisks.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package glesys
import "context"
// ServerDisksService provides functions to interact with serverdisks
type ServerDisksService struct {
client clientInterface
}
// CreateServerDiskParams specifies the details for a new serverdisk
type CreateServerDiskParams struct {
Name string `json:"name"`
ServerID string `json:"serverid"`
SizeInGIB int `json:"sizeingib"`
Type string `json:"type,omitempty"`
}
// ServerDiskDetails represents any extra disks for a server
type ServerDiskDetails struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
SizeInGIB int `json:"sizeingib"`
SCSIID int `json:"scsiid"`
Type string `json:"type"`
}
// ServerDiskReconfigureParams parameters for updating a ServerDisk
type EditServerDiskParams struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
SizeInGIB int `json:"sizeingib,omitempty"`
}
// ServerDiskLimitsDetails represents the disk limits for a server
type ServerDiskLimitsDetails struct {
MinSizeInGIB int `json:"minsizeingib"`
MaxSizeInGIB int `json:"maxsizeingib"`
MaxNumDisks int `json:"maxnumdisks"`
CurrentNumDisks int `json:"currentnumdisks"`
}
// Create - Creates an additional serverdisk using CreateServerDiskParams
func (s *ServerDisksService) Create(context context.Context, params CreateServerDiskParams) (*ServerDiskDetails, error) {
data := struct {
Response struct {
Disk ServerDiskDetails
}
}{}
err := s.client.post(context, "serverdisk/create", &data, params)
return &data.Response.Disk, err
}
// UpdateName - Modifies a serverdisk name using EditServerDiskParams
func (s *ServerDisksService) UpdateName(context context.Context, params EditServerDiskParams) (*ServerDiskDetails, error) {
data := struct {
Response struct {
Disk ServerDiskDetails
}
}{}
err := s.client.post(context, "serverdisk/updatename", &data, params)
return &data.Response.Disk, err
}
// Reconfigure - Modifies a serverdisk using EditServerDiskParams
func (s *ServerDisksService) Reconfigure(context context.Context, params EditServerDiskParams) (*ServerDiskDetails, error) {
data := struct {
Response struct {
Disk ServerDiskDetails
}
}{}
err := s.client.post(context, "serverdisk/reconfigure", &data, params)
return &data.Response.Disk, err
}
// Delete - deletes a serverdisk
func (s *ServerDisksService) Delete(context context.Context, diskID string) error {
return s.client.post(context, "serverdisk/delete", nil, struct {
DiskID string `json:"id"`
}{diskID})
}
// Limits - retrieve serverdisk limits for a specific server
func (s *ServerDisksService) Limits(context context.Context, serverID string) (*ServerDiskLimitsDetails, error) {
data := struct {
Response struct {
Limits ServerDiskLimitsDetails
}
}{}
err := s.client.post(context, "serverdisk/limits", &data,
struct {
ServerID string `json:"serverid"`
}{serverID})
return &data.Response.Limits, err
}