Skip to content

Commit

Permalink
Add Type attribute to ServerDisks
Browse files Browse the repository at this point in the history
When creating new ServerDisks, use the Type attribute to set disk policy for the
additional disk.
  • Loading branch information
norrland committed Oct 1, 2024
1 parent 9569c9f commit 39ff73f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Implemented `server/listiso` and `server/mountiso` endpoints.
### Changed
- Add `ISOFile` attribute in `ServerDetails`.
- Add `Type` attribute for disk policy in `ServerDiskDetails`.

## [8.3.1] - 2024-09-19
### Changed
Expand Down
3 changes: 2 additions & 1 deletion doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,14 +684,15 @@ func ExampleServerDisksService_Create() {
ServerID: "wps123456",
SizeInGIB: 125,
Name: "Extra disk",
Type: "silver", // [gold|silver]
}

_, _ = client.ServerDisks.Create(context.Background(), params)

server, _ := client.Servers.Details(context.Background(), "wps123456")

for _, disk := range server.AdditionalDisks {
fmt.Printf("Disk%d: %s - %d\n", disk.SCSIID, disk.Name, disk.SizeInGIB)
fmt.Printf("Disk%d: %s - %d - Type: %s\n", disk.SCSIID, disk.Name, disk.SizeInGIB, disk.Type)
}
}

Expand Down
2 changes: 2 additions & 0 deletions serverdisks.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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
Expand All @@ -20,6 +21,7 @@ type ServerDiskDetails struct {
Name string `json:"name,omitempty"`
SizeInGIB int `json:"sizeingib"`
SCSIID int `json:"scsiid"`
Type string `json:"type"`
}

// ServerDiskReconfigureParams parameters for updating a ServerDisk
Expand Down
4 changes: 3 additions & 1 deletion serverdisks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ func TestServerDisk_Create(t *testing.T) {
c := &mockClient{body: `{ "response": { "disk": { "id": "aaaaa-bbbbbb-cccccc",
"sizeingib": 200,
"name": "Diskett",
"scsiid": 1
"scsiid": 1,
"type": "gold"
}}}`}
s := ServerDisksService{client: c}

Expand All @@ -26,6 +27,7 @@ func TestServerDisk_Create(t *testing.T) {
assert.Equal(t, "serverdisk/create", c.lastPath, "correct path is used")
assert.Equal(t, 200, disk.SizeInGIB, "size is correct")
assert.Equal(t, "Diskett", disk.Name, "correct name variable")
assert.Equal(t, "gold", disk.Type, "correct type variable")
}

func TestServerDisk_UpdateName(t *testing.T) {
Expand Down

0 comments on commit 39ff73f

Please sign in to comment.