File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,12 +3,12 @@ package client
33import (
44 "bytes"
55 "fmt"
6- "github.com/blang/semver"
7- "github.com/hashicorp/go-cleanhttp"
86 "io"
97 "io/ioutil"
108 "net/http"
119 "time"
10+
11+ "github.com/blang/semver"
1212)
1313
1414// Constants
@@ -50,6 +50,11 @@ func (c *Client) SetTimeout(timeout time.Duration) {
5050 c .httpClient .Timeout = timeout
5151}
5252
53+ // GetTimeout returns current timeout
54+ func (c * Client ) GetTimeout () time.Duration {
55+ return c .httpClient .Timeout
56+ }
57+
5358// CreateRequestUrl creates and returns a complete request URL for the specified API location
5459func (c * Client ) CreateRequestUrl (location string ) string {
5560 return fmt .Sprintf ("%s%s" , c .getBaseUrl (), location )
Original file line number Diff line number Diff line change @@ -3,10 +3,11 @@ package service
33import (
44 "encoding/xml"
55 "fmt"
6+ "time"
7+
68 "github.com/UpCloudLtd/upcloud-go-api/upcloud"
79 "github.com/UpCloudLtd/upcloud-go-api/upcloud/client"
810 "github.com/UpCloudLtd/upcloud-go-api/upcloud/request"
9- "time"
1011)
1112
1213// Service represents the API service. The specified client is used to communicate with the API
@@ -185,12 +186,18 @@ func (s *Service) WaitForServerState(r *request.WaitForServerStateRequest) (*upc
185186
186187// StartServer starts the specified server
187188func (s * Service ) StartServer (r * request.StartServerRequest ) (* upcloud.ServerDetails , error ) {
189+ // Save previous timeout
190+ prevTimeout := s .client .GetTimeout ()
191+
188192 // Increase the client timeout to match the request timeout
189193 s .client .SetTimeout (r .Timeout )
190194
191195 serverDetails := upcloud.ServerDetails {}
192196 response , err := s .client .PerformPostRequest (s .client .CreateRequestUrl (r .RequestURL ()), nil )
193197
198+ // Restore previous timout
199+ s .client .SetTimeout (prevTimeout )
200+
194201 if err != nil {
195202 return nil , parseServiceError (err )
196203 }
You can’t perform that action at this time.
0 commit comments