diff --git a/go.mod b/go.mod index a5ef43b58ac0ebcbaabd5dda36957c19d0053476..a8436ec236745b18b9557d13c213d2522b60d526 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module hcloud-dynfw go 1.16 -require github.com/hetznercloud/hcloud-go v1.35.3 +require github.com/hetznercloud/hcloud-go v1.37.0 diff --git a/go.sum b/go.sum index bb3406656a8c961303c1d66c683c22a6f5a9c3ab..2d11527e3f5628e586b49ea0cf0e29925f601dfb 100644 --- a/go.sum +++ b/go.sum @@ -41,6 +41,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/hetznercloud/hcloud-go v1.35.3 h1:WCmFAhLRooih2QHAsbCbEdpIHnshQQmrPqsr3rHE1Ow= github.com/hetznercloud/hcloud-go v1.35.3/go.mod h1:mepQwR6va27S3UQthaEPGS86jtzSY9xWL1e9dyxXpgA= +github.com/hetznercloud/hcloud-go v1.37.0 h1:Uwu7OKfZvar86LfJuzItStoO1AL7DVDCqWzRGzrvdEw= +github.com/hetznercloud/hcloud-go v1.37.0/go.mod h1:mepQwR6va27S3UQthaEPGS86jtzSY9xWL1e9dyxXpgA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= diff --git a/vendor/github.com/hetznercloud/hcloud-go/hcloud/hcloud.go b/vendor/github.com/hetznercloud/hcloud-go/hcloud/hcloud.go index f850a351806f5adf4c8cc1394784de4465705388..e8dd6192002bd53d3ae7f334db4eb90dbc748ed3 100644 --- a/vendor/github.com/hetznercloud/hcloud-go/hcloud/hcloud.go +++ b/vendor/github.com/hetznercloud/hcloud-go/hcloud/hcloud.go @@ -2,4 +2,4 @@ package hcloud // Version is the library's version following Semantic Versioning. -const Version = "1.35.2" +const Version = "1.37.0" diff --git a/vendor/github.com/hetznercloud/hcloud-go/hcloud/primary_ip.go b/vendor/github.com/hetznercloud/hcloud-go/hcloud/primary_ip.go index c534c89a67e104923c4db0fc6097080417823ba9..66cc41483b6c4c7172da48c9a8c7b3327045e8d7 100644 --- a/vendor/github.com/hetznercloud/hcloud-go/hcloud/primary_ip.go +++ b/vendor/github.com/hetznercloud/hcloud-go/hcloud/primary_ip.go @@ -90,12 +90,6 @@ type PrimaryIPUpdateOpts struct { Name string `json:"name,omitempty"` } -// PrimaryIPUpdateResult defines the response -// when updating a Primary IP. -type PrimaryIPUpdateResult struct { - PrimaryIP PrimaryIP `json:"primary_ip"` -} - // PrimaryIPAssignOpts defines the request to // assign a Primary IP to an assignee (usually a server). type PrimaryIPAssignOpts struct { @@ -240,10 +234,12 @@ func (c *PrimaryIPClient) List(ctx context.Context, opts PrimaryIPListOpts) ([]* // All returns all Primary IPs. func (c *PrimaryIPClient) All(ctx context.Context) ([]*PrimaryIP, error) { - allPrimaryIPs := []*PrimaryIP{} + return c.AllWithOpts(ctx, PrimaryIPListOpts{ListOpts: ListOpts{PerPage: 50}}) +} - opts := PrimaryIPListOpts{} - opts.PerPage = 50 +// AllWithOpts returns all Primary IPs for the given options. +func (c *PrimaryIPClient) AllWithOpts(ctx context.Context, opts PrimaryIPListOpts) ([]*PrimaryIP, error) { + var allPrimaryIPs []*PrimaryIP err := c.client.all(func(page int) (*Response, error) { opts.Page = page @@ -311,12 +307,12 @@ func (c *PrimaryIPClient) Update(ctx context.Context, primaryIP *PrimaryIP, reqB return nil, nil, err } - respBody := PrimaryIPUpdateResult{} + var respBody schema.PrimaryIPUpdateResult resp, err := c.client.Do(req, &respBody) if err != nil { return nil, resp, err } - return &respBody.PrimaryIP, resp, nil + return PrimaryIPFromSchema(respBody.PrimaryIP), resp, nil } // Assign a Primary IP to a resource diff --git a/vendor/github.com/hetznercloud/hcloud-go/hcloud/schema/primary_ip.go b/vendor/github.com/hetznercloud/hcloud-go/hcloud/schema/primary_ip.go index b21e28b4a8b480754f78944d276f70e6fa335de5..1cfb0847242d136ae083dec068c135dc9b1ae492 100644 --- a/vendor/github.com/hetznercloud/hcloud-go/hcloud/schema/primary_ip.go +++ b/vendor/github.com/hetznercloud/hcloud-go/hcloud/schema/primary_ip.go @@ -47,3 +47,9 @@ type PrimaryIPGetResult struct { type PrimaryIPListResult struct { PrimaryIPs []PrimaryIP `json:"primary_ips"` } + +// PrimaryIPUpdateResult defines the response +// when updating a Primary IP. +type PrimaryIPUpdateResult struct { + PrimaryIP PrimaryIP `json:"primary_ip"` +} diff --git a/vendor/github.com/hetznercloud/hcloud-go/hcloud/schema/server.go b/vendor/github.com/hetznercloud/hcloud-go/hcloud/schema/server.go index 616b2eb4d3a295fe9fdc6fe5185029d510521355..654ccfc6da044dae3c88a9e96e6b23dd47a070f2 100644 --- a/vendor/github.com/hetznercloud/hcloud-go/hcloud/schema/server.go +++ b/vendor/github.com/hetznercloud/hcloud-go/hcloud/schema/server.go @@ -136,6 +136,12 @@ type ServerCreateResponse struct { NextActions []Action `json:"next_actions"` } +// ServerDeleteResponse defines the schema of the response when +// deleting a server. +type ServerDeleteResponse struct { + Action Action `json:"action"` +} + // ServerUpdateRequest defines the schema of the request to update a server. type ServerUpdateRequest struct { Name string `json:"name,omitempty"` diff --git a/vendor/github.com/hetznercloud/hcloud-go/hcloud/server.go b/vendor/github.com/hetznercloud/hcloud-go/hcloud/server.go index 00bcb90331347877c244e5e9ba2149e015c486b3..707425d4fb83e55aeb2c72e085586262b75f09ec 100644 --- a/vendor/github.com/hetznercloud/hcloud-go/hcloud/server.go +++ b/vendor/github.com/hetznercloud/hcloud-go/hcloud/server.go @@ -458,13 +458,34 @@ func (c *ServerClient) Create(ctx context.Context, opts ServerCreateOpts) (Serve return result, resp, nil } +// ServerDeleteResult is the result of a delete server call. +type ServerDeleteResult struct { + Action *Action +} + // Delete deletes a server. +// This method is deprecated, use ServerClient.DeleteWithResult instead. func (c *ServerClient) Delete(ctx context.Context, server *Server) (*Response, error) { + _, resp, err := c.DeleteWithResult(ctx, server) + return resp, err +} + +// Delete deletes a server and returns the parsed response containing the action. +func (c *ServerClient) DeleteWithResult(ctx context.Context, server *Server) (*ServerDeleteResult, *Response, error) { req, err := c.client.NewRequest(ctx, "DELETE", fmt.Sprintf("/servers/%d", server.ID), nil) if err != nil { - return nil, err + return &ServerDeleteResult{}, nil, err } - return c.client.Do(req, nil) + + var respBody schema.ServerDeleteResponse + resp, err := c.client.Do(req, &respBody) + if err != nil { + return &ServerDeleteResult{}, resp, err + } + + return &ServerDeleteResult{ + Action: ActionFromSchema(respBody.Action), + }, resp, nil } // ServerUpdateOpts specifies options for updating a server. diff --git a/vendor/modules.txt b/vendor/modules.txt index 7a6cc1d4038ab62c8d2bf32e6d1b2cf11067dfda..ed076b138deec7d6d8d554da55d834dab453b8a5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -8,7 +8,7 @@ github.com/golang/protobuf/ptypes github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes/duration github.com/golang/protobuf/ptypes/timestamp -# github.com/hetznercloud/hcloud-go v1.35.3 +# github.com/hetznercloud/hcloud-go v1.37.0 ## explicit github.com/hetznercloud/hcloud-go/hcloud github.com/hetznercloud/hcloud-go/hcloud/internal/instrumentation