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 bm start call, update paging description #118

Merged
merged 2 commits into from
Dec 17, 2020
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type Links struct {
}

```
Pass a `per_page` value to the `list_options` struct to adjust the number of items returned per call. The default and max are 25 items per page.
Pass a `per_page` value to the `list_options` struct to adjust the number of items returned per call. The default is 100 items per page and max is 500 items per page.

This example demonstrates how to retrieve all of your instances, with one instance per page.

Expand Down
12 changes: 12 additions & 0 deletions bare_metal_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type BareMetalServerService interface {

Halt(ctx context.Context, serverID string) error
Reboot(ctx context.Context, serverID string) error
Start(ctx context.Context, serverID string) error
Reinstall(ctx context.Context, serverID string) (*BareMetalServer, error)

MassStart(ctx context.Context, serverList []string) error
Expand Down Expand Up @@ -326,6 +327,17 @@ func (b *BareMetalServerServiceHandler) Reboot(ctx context.Context, serverID str
return b.client.DoWithContext(ctx, req, nil)
}

// Start a Bare Metal server.
func (b *BareMetalServerServiceHandler) Start(ctx context.Context, serverID string) error {
uri := fmt.Sprintf("%s/%s/start", bmPath, serverID)
req, err := b.client.NewRequest(ctx, http.MethodPost, uri, nil)
if err != nil {
return err
}

return b.client.DoWithContext(ctx, req, nil)
}

// Reinstall the operating system on a Bare Metal server.
// All data will be permanently lost, but the IP address will remain the same.
func (b *BareMetalServerServiceHandler) Reinstall(ctx context.Context, serverID string) (*BareMetalServer, error) {
Expand Down
15 changes: 15 additions & 0 deletions bare_metal_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,21 @@ func TestBareMetalServerServiceHandler_Reinstall(t *testing.T) {
}
}

func TestBareMetalServerServiceHandler_Start(t *testing.T) {
setup()
defer teardown()

mux.HandleFunc("/v2/bare-metals/42018b7b-a4e3-4c7e-be74-663afeb142aa/start", func(writer http.ResponseWriter, request *http.Request) {
fmt.Fprint(writer)
})

err := client.BareMetalServer.Start(ctx, "42018b7b-a4e3-4c7e-be74-663afeb142aa")

if err != nil {
t.Errorf("BareMetalServer.Start returned %+v, expected %+v", err, nil)
}
}

func TestBareMetalServerServiceHandler_GetUserData(t *testing.T) {
setup()
defer teardown()
Expand Down
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVo
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
github.com/hashicorp/go-retryablehttp v0.6.6 h1:HJunrbHTDDbBb/ay4kxa1n+dLmttUlnP3V9oNE4hmsM=
github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
github.com/hashicorp/go-retryablehttp v0.6.8 h1:92lWxgpa+fF3FozM4B3UZtHZMJX8T5XT+TFdCxsPyWs=
github.com/hashicorp/go-retryablehttp v0.6.8/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down