Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Type attribute to ServerDisks #124

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading