@@ -135,8 +135,12 @@ type CreateServerNetworking struct {
135135
136136// CreateServerRequest represents a request for creating a new server
137137type CreateServerRequest struct {
138- AvoidHost int `json:"avoid_host,omitempty"`
139- Host int `json:"host,omitempty"`
138+ // Deprecated: Use AvoidHostID instead.
139+ AvoidHost int `json:"-"`
140+ AvoidHostID int64 `json:"-"`
141+ // Deprecated: Use HostID instead.
142+ Host int `json:"-"`
143+ HostID int64 `json:"-"`
140144 BootOrder string `json:"boot_order,omitempty"`
141145 CoreNumber int `json:"core_number,omitempty"`
142146 // TODO: Convert to boolean
@@ -168,9 +172,16 @@ type CreateServerRequest struct {
168172func (r CreateServerRequest ) MarshalJSON () ([]byte , error ) {
169173 type localCreateServerRequest CreateServerRequest
170174 v := struct {
171- Server localCreateServerRequest `json:"server"`
175+ Server struct {
176+ localCreateServerRequest
177+
178+ AvoidHost * int64 `json:"avoid_host,omitempty"`
179+ Host * int64 `json:"host,omitempty"`
180+ } `json:"server"`
172181 }{}
173- v .Server = localCreateServerRequest (r )
182+ v .Server .localCreateServerRequest = localCreateServerRequest (r )
183+ v .Server .AvoidHost = hostIDPtr (r .AvoidHost , r .AvoidHostID )
184+ v .Server .Host = hostIDPtr (r .Host , r .HostID )
174185
175186 return json .Marshal (& v )
176187}
@@ -234,9 +245,13 @@ type WaitForServerStateRequest struct {
234245
235246// StartServerRequest represents a request to start a server
236247type StartServerRequest struct {
237- UUID string `json:"-"`
238- AvoidHost int `json:"avoid_host,omitempty"`
239- Host int `json:"host,omitempty"`
248+ UUID string `json:"-"`
249+ // Deprecated: Use AvoidHostID instead.
250+ AvoidHost int `json:"-"`
251+ AvoidHostID int64 `json:"-"`
252+ // Deprecated: Use HostID instead.
253+ Host int `json:"-"`
254+ HostID int64 `json:"-"`
240255}
241256
242257// RequestURL implements the Request interface
@@ -249,9 +264,16 @@ func (r *StartServerRequest) RequestURL() string {
249264func (r StartServerRequest ) MarshalJSON () ([]byte , error ) {
250265 type localStartServerRequest StartServerRequest
251266 v := struct {
252- Server localStartServerRequest `json:"server"`
267+ Server struct {
268+ localStartServerRequest
269+
270+ AvoidHost * int64 `json:"avoid_host,omitempty"`
271+ Host * int64 `json:"host,omitempty"`
272+ } `json:"server"`
253273 }{}
254- v .Server = localStartServerRequest (r )
274+ v .Server .localStartServerRequest = localStartServerRequest (r )
275+ v .Server .AvoidHost = hostIDPtr (r .AvoidHost , r .AvoidHostID )
276+ v .Server .Host = hostIDPtr (r .Host , r .HostID )
255277
256278 return json .Marshal (& v )
257279}
@@ -289,7 +311,9 @@ type RestartServerRequest struct {
289311 StopType string `json:"stop_type,omitempty"`
290312 Timeout time.Duration `json:"timeout,omitempty,string"`
291313 TimeoutAction string `json:"timeout_action,omitempty"`
292- Host int `json:"host,omitempty"`
314+ // Deprecated: Use HostID instead.
315+ Host int `json:"-"`
316+ HostID int64 `json:"-"`
293317}
294318
295319// RequestURL implements the Request interface
@@ -302,14 +326,36 @@ func (r *RestartServerRequest) RequestURL() string {
302326func (r RestartServerRequest ) MarshalJSON () ([]byte , error ) {
303327 type localRestartServerRequest RestartServerRequest
304328 v := struct {
305- RestartServerRequest localRestartServerRequest `json:"restart_server"`
329+ RestartServerRequest struct {
330+ localRestartServerRequest
331+
332+ Host * int64 `json:"host,omitempty"`
333+ } `json:"restart_server"`
306334 }{}
307- v .RestartServerRequest = localRestartServerRequest (r )
335+ v .RestartServerRequest . localRestartServerRequest = localRestartServerRequest (r )
308336 v .RestartServerRequest .Timeout = v .RestartServerRequest .Timeout / 1e9
337+ v .RestartServerRequest .Host = hostIDPtr (r .Host , r .HostID )
309338
310339 return json .Marshal (& v )
311340}
312341
342+ func hostIDValue (id int , hostID int64 ) int64 {
343+ if hostID != 0 {
344+ return hostID
345+ }
346+
347+ return int64 (id )
348+ }
349+
350+ func hostIDPtr (id int , hostID int64 ) * int64 {
351+ resolved := hostIDValue (id , hostID )
352+ if resolved == 0 {
353+ return nil
354+ }
355+
356+ return & resolved
357+ }
358+
313359// ModifyServerRequest represents a request to modify a server
314360type ModifyServerRequest struct {
315361 UUID string `json:"-"`
0 commit comments