From a0aa1581a0fd0bbeda779534d44b0ba7aa4f44ca Mon Sep 17 00:00:00 2001 From: Mariah McLaughlin Date: Thu, 17 Dec 2020 12:37:15 -0500 Subject: [PATCH 1/2] add bm start call, update paging description --- README.md | 2 +- bare_metal_server.go | 12 ++++++++++++ bare_metal_server_test.go | 15 +++++++++++++++ go.sum | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c04a58b..3fa078d 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/bare_metal_server.go b/bare_metal_server.go index d558b2a..7bdcedc 100644 --- a/bare_metal_server.go +++ b/bare_metal_server.go @@ -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 @@ -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) { diff --git a/bare_metal_server_test.go b/bare_metal_server_test.go index abeb977..2a45b38 100644 --- a/bare_metal_server_test.go +++ b/bare_metal_server_test.go @@ -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() diff --git a/go.sum b/go.sum index 1b7b13f..3610b97 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,7 @@ github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxC 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= From ef349f210db9ca694179d437ed04bcbd1ab52aa3 Mon Sep 17 00:00:00 2001 From: Mariah McLaughlin Date: Thu, 17 Dec 2020 13:02:55 -0500 Subject: [PATCH 2/2] run go mod tidy --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index 3610b97..01c9f71 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,6 @@ 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=