1package batch 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/autorest/date" 25 "github.com/Azure/go-autorest/autorest/validation" 26 "github.com/satori/go.uuid" 27 "net/http" 28) 29 30// ComputeNodeClient is the a client for issuing REST requests to the Azure Batch service. 31type ComputeNodeClient struct { 32 BaseClient 33} 34 35// NewComputeNodeClient creates an instance of the ComputeNodeClient client. 36func NewComputeNodeClient() ComputeNodeClient { 37 return NewComputeNodeClientWithBaseURI(DefaultBaseURI) 38} 39 40// NewComputeNodeClientWithBaseURI creates an instance of the ComputeNodeClient client. 41func NewComputeNodeClientWithBaseURI(baseURI string) ComputeNodeClient { 42 return ComputeNodeClient{NewWithBaseURI(baseURI)} 43} 44 45// AddUser you can add a user account to a node only when it is in the idle or running state. 46// 47// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the machine on which you want 48// to create a user account. userParameter is the user account to be created. timeout is the maximum time that the 49// server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is the 50// caller-generated request identity, in the form of a GUID with no decoration such as curly braces, e.g. 51// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the 52// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set 53// this to the current system clock time; set it explicitly if you are calling the REST API directly. 54func (client ComputeNodeClient) AddUser(ctx context.Context, poolID string, nodeID string, userParameter ComputeNodeUser, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 55 if err := validation.Validate([]validation.Validation{ 56 {TargetValue: userParameter, 57 Constraints: []validation.Constraint{{Target: "userParameter.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 58 return result, validation.NewError("batch.ComputeNodeClient", "AddUser", err.Error()) 59 } 60 61 req, err := client.AddUserPreparer(ctx, poolID, nodeID, userParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "AddUser", nil, "Failure preparing request") 64 return 65 } 66 67 resp, err := client.AddUserSender(req) 68 if err != nil { 69 result.Response = resp 70 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "AddUser", resp, "Failure sending request") 71 return 72 } 73 74 result, err = client.AddUserResponder(resp) 75 if err != nil { 76 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "AddUser", resp, "Failure responding to request") 77 } 78 79 return 80} 81 82// AddUserPreparer prepares the AddUser request. 83func (client ComputeNodeClient) AddUserPreparer(ctx context.Context, poolID string, nodeID string, userParameter ComputeNodeUser, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 84 pathParameters := map[string]interface{}{ 85 "nodeId": autorest.Encode("path", nodeID), 86 "poolId": autorest.Encode("path", poolID), 87 } 88 89 const APIVersion = "2017-09-01.6.0" 90 queryParameters := map[string]interface{}{ 91 "api-version": APIVersion, 92 } 93 if timeout != nil { 94 queryParameters["timeout"] = autorest.Encode("query", *timeout) 95 } else { 96 queryParameters["timeout"] = autorest.Encode("query", 30) 97 } 98 99 preparer := autorest.CreatePreparer( 100 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 101 autorest.AsPost(), 102 autorest.WithBaseURL(client.BaseURI), 103 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/users", pathParameters), 104 autorest.WithJSON(userParameter), 105 autorest.WithQueryParameters(queryParameters)) 106 if clientRequestID != nil { 107 preparer = autorest.DecoratePreparer(preparer, 108 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 109 } 110 if returnClientRequestID != nil { 111 preparer = autorest.DecoratePreparer(preparer, 112 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 113 } else { 114 preparer = autorest.DecoratePreparer(preparer, 115 autorest.WithHeader("return-client-request-id", autorest.String(false))) 116 } 117 if ocpDate != nil { 118 preparer = autorest.DecoratePreparer(preparer, 119 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 120 } 121 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 122} 123 124// AddUserSender sends the AddUser request. The method will close the 125// http.Response Body if it receives an error. 126func (client ComputeNodeClient) AddUserSender(req *http.Request) (*http.Response, error) { 127 return autorest.SendWithSender(client, req, 128 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 129} 130 131// AddUserResponder handles the response to the AddUser request. The method always 132// closes the http.Response Body. 133func (client ComputeNodeClient) AddUserResponder(resp *http.Response) (result autorest.Response, err error) { 134 err = autorest.Respond( 135 resp, 136 client.ByInspecting(), 137 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 138 autorest.ByClosing()) 139 result.Response = resp 140 return 141} 142 143// DeleteUser you can delete a user account to a node only when it is in the idle or running state. 144// 145// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the machine on which you want 146// to delete a user account. userName is the name of the user account to delete. timeout is the maximum time that 147// the server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is the 148// caller-generated request identity, in the form of a GUID with no decoration such as curly braces, e.g. 149// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the 150// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set 151// this to the current system clock time; set it explicitly if you are calling the REST API directly. 152func (client ComputeNodeClient) DeleteUser(ctx context.Context, poolID string, nodeID string, userName string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 153 req, err := client.DeleteUserPreparer(ctx, poolID, nodeID, userName, timeout, clientRequestID, returnClientRequestID, ocpDate) 154 if err != nil { 155 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DeleteUser", nil, "Failure preparing request") 156 return 157 } 158 159 resp, err := client.DeleteUserSender(req) 160 if err != nil { 161 result.Response = resp 162 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DeleteUser", resp, "Failure sending request") 163 return 164 } 165 166 result, err = client.DeleteUserResponder(resp) 167 if err != nil { 168 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DeleteUser", resp, "Failure responding to request") 169 } 170 171 return 172} 173 174// DeleteUserPreparer prepares the DeleteUser request. 175func (client ComputeNodeClient) DeleteUserPreparer(ctx context.Context, poolID string, nodeID string, userName string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 176 pathParameters := map[string]interface{}{ 177 "nodeId": autorest.Encode("path", nodeID), 178 "poolId": autorest.Encode("path", poolID), 179 "userName": autorest.Encode("path", userName), 180 } 181 182 const APIVersion = "2017-09-01.6.0" 183 queryParameters := map[string]interface{}{ 184 "api-version": APIVersion, 185 } 186 if timeout != nil { 187 queryParameters["timeout"] = autorest.Encode("query", *timeout) 188 } else { 189 queryParameters["timeout"] = autorest.Encode("query", 30) 190 } 191 192 preparer := autorest.CreatePreparer( 193 autorest.AsDelete(), 194 autorest.WithBaseURL(client.BaseURI), 195 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/users/{userName}", pathParameters), 196 autorest.WithQueryParameters(queryParameters)) 197 if clientRequestID != nil { 198 preparer = autorest.DecoratePreparer(preparer, 199 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 200 } 201 if returnClientRequestID != nil { 202 preparer = autorest.DecoratePreparer(preparer, 203 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 204 } else { 205 preparer = autorest.DecoratePreparer(preparer, 206 autorest.WithHeader("return-client-request-id", autorest.String(false))) 207 } 208 if ocpDate != nil { 209 preparer = autorest.DecoratePreparer(preparer, 210 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 211 } 212 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 213} 214 215// DeleteUserSender sends the DeleteUser request. The method will close the 216// http.Response Body if it receives an error. 217func (client ComputeNodeClient) DeleteUserSender(req *http.Request) (*http.Response, error) { 218 return autorest.SendWithSender(client, req, 219 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 220} 221 222// DeleteUserResponder handles the response to the DeleteUser request. The method always 223// closes the http.Response Body. 224func (client ComputeNodeClient) DeleteUserResponder(resp *http.Response) (result autorest.Response, err error) { 225 err = autorest.Respond( 226 resp, 227 client.ByInspecting(), 228 azure.WithErrorUnlessStatusCode(http.StatusOK), 229 autorest.ByClosing()) 230 result.Response = resp 231 return 232} 233 234// DisableScheduling you can disable task scheduling on a node only if its current scheduling state is enabled. 235// 236// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the compute node on which you 237// want to disable task scheduling. nodeDisableSchedulingParameter is the parameters for the request. timeout is 238// the maximum time that the server can spend processing the request, in seconds. The default is 30 seconds. 239// clientRequestID is the caller-generated request identity, in the form of a GUID with no decoration such as curly 240// braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the 241// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set 242// this to the current system clock time; set it explicitly if you are calling the REST API directly. 243func (client ComputeNodeClient) DisableScheduling(ctx context.Context, poolID string, nodeID string, nodeDisableSchedulingParameter *NodeDisableSchedulingParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 244 req, err := client.DisableSchedulingPreparer(ctx, poolID, nodeID, nodeDisableSchedulingParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 245 if err != nil { 246 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DisableScheduling", nil, "Failure preparing request") 247 return 248 } 249 250 resp, err := client.DisableSchedulingSender(req) 251 if err != nil { 252 result.Response = resp 253 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DisableScheduling", resp, "Failure sending request") 254 return 255 } 256 257 result, err = client.DisableSchedulingResponder(resp) 258 if err != nil { 259 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DisableScheduling", resp, "Failure responding to request") 260 } 261 262 return 263} 264 265// DisableSchedulingPreparer prepares the DisableScheduling request. 266func (client ComputeNodeClient) DisableSchedulingPreparer(ctx context.Context, poolID string, nodeID string, nodeDisableSchedulingParameter *NodeDisableSchedulingParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 267 pathParameters := map[string]interface{}{ 268 "nodeId": autorest.Encode("path", nodeID), 269 "poolId": autorest.Encode("path", poolID), 270 } 271 272 const APIVersion = "2017-09-01.6.0" 273 queryParameters := map[string]interface{}{ 274 "api-version": APIVersion, 275 } 276 if timeout != nil { 277 queryParameters["timeout"] = autorest.Encode("query", *timeout) 278 } else { 279 queryParameters["timeout"] = autorest.Encode("query", 30) 280 } 281 282 preparer := autorest.CreatePreparer( 283 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 284 autorest.AsPost(), 285 autorest.WithBaseURL(client.BaseURI), 286 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/disablescheduling", pathParameters), 287 autorest.WithQueryParameters(queryParameters)) 288 if nodeDisableSchedulingParameter != nil { 289 preparer = autorest.DecoratePreparer(preparer, 290 autorest.WithJSON(nodeDisableSchedulingParameter)) 291 } 292 if clientRequestID != nil { 293 preparer = autorest.DecoratePreparer(preparer, 294 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 295 } 296 if returnClientRequestID != nil { 297 preparer = autorest.DecoratePreparer(preparer, 298 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 299 } else { 300 preparer = autorest.DecoratePreparer(preparer, 301 autorest.WithHeader("return-client-request-id", autorest.String(false))) 302 } 303 if ocpDate != nil { 304 preparer = autorest.DecoratePreparer(preparer, 305 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 306 } 307 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 308} 309 310// DisableSchedulingSender sends the DisableScheduling request. The method will close the 311// http.Response Body if it receives an error. 312func (client ComputeNodeClient) DisableSchedulingSender(req *http.Request) (*http.Response, error) { 313 return autorest.SendWithSender(client, req, 314 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 315} 316 317// DisableSchedulingResponder handles the response to the DisableScheduling request. The method always 318// closes the http.Response Body. 319func (client ComputeNodeClient) DisableSchedulingResponder(resp *http.Response) (result autorest.Response, err error) { 320 err = autorest.Respond( 321 resp, 322 client.ByInspecting(), 323 azure.WithErrorUnlessStatusCode(http.StatusOK), 324 autorest.ByClosing()) 325 result.Response = resp 326 return 327} 328 329// EnableScheduling you can enable task scheduling on a node only if its current scheduling state is disabled 330// 331// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the compute node on which you 332// want to enable task scheduling. timeout is the maximum time that the server can spend processing the request, in 333// seconds. The default is 30 seconds. clientRequestID is the caller-generated request identity, in the form of a 334// GUID with no decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID 335// is whether the server should return the client-request-id in the response. ocpDate is the time the request was 336// issued. Client libraries typically set this to the current system clock time; set it explicitly if you are 337// calling the REST API directly. 338func (client ComputeNodeClient) EnableScheduling(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 339 req, err := client.EnableSchedulingPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate) 340 if err != nil { 341 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "EnableScheduling", nil, "Failure preparing request") 342 return 343 } 344 345 resp, err := client.EnableSchedulingSender(req) 346 if err != nil { 347 result.Response = resp 348 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "EnableScheduling", resp, "Failure sending request") 349 return 350 } 351 352 result, err = client.EnableSchedulingResponder(resp) 353 if err != nil { 354 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "EnableScheduling", resp, "Failure responding to request") 355 } 356 357 return 358} 359 360// EnableSchedulingPreparer prepares the EnableScheduling request. 361func (client ComputeNodeClient) EnableSchedulingPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 362 pathParameters := map[string]interface{}{ 363 "nodeId": autorest.Encode("path", nodeID), 364 "poolId": autorest.Encode("path", poolID), 365 } 366 367 const APIVersion = "2017-09-01.6.0" 368 queryParameters := map[string]interface{}{ 369 "api-version": APIVersion, 370 } 371 if timeout != nil { 372 queryParameters["timeout"] = autorest.Encode("query", *timeout) 373 } else { 374 queryParameters["timeout"] = autorest.Encode("query", 30) 375 } 376 377 preparer := autorest.CreatePreparer( 378 autorest.AsPost(), 379 autorest.WithBaseURL(client.BaseURI), 380 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/enablescheduling", pathParameters), 381 autorest.WithQueryParameters(queryParameters)) 382 if clientRequestID != nil { 383 preparer = autorest.DecoratePreparer(preparer, 384 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 385 } 386 if returnClientRequestID != nil { 387 preparer = autorest.DecoratePreparer(preparer, 388 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 389 } else { 390 preparer = autorest.DecoratePreparer(preparer, 391 autorest.WithHeader("return-client-request-id", autorest.String(false))) 392 } 393 if ocpDate != nil { 394 preparer = autorest.DecoratePreparer(preparer, 395 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 396 } 397 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 398} 399 400// EnableSchedulingSender sends the EnableScheduling request. The method will close the 401// http.Response Body if it receives an error. 402func (client ComputeNodeClient) EnableSchedulingSender(req *http.Request) (*http.Response, error) { 403 return autorest.SendWithSender(client, req, 404 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 405} 406 407// EnableSchedulingResponder handles the response to the EnableScheduling request. The method always 408// closes the http.Response Body. 409func (client ComputeNodeClient) EnableSchedulingResponder(resp *http.Response) (result autorest.Response, err error) { 410 err = autorest.Respond( 411 resp, 412 client.ByInspecting(), 413 azure.WithErrorUnlessStatusCode(http.StatusOK), 414 autorest.ByClosing()) 415 result.Response = resp 416 return 417} 418 419// Get sends the get request. 420// 421// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the compute node that you want 422// to get information about. selectParameter is an OData $select clause. timeout is the maximum time that the 423// server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is the 424// caller-generated request identity, in the form of a GUID with no decoration such as curly braces, e.g. 425// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the 426// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set 427// this to the current system clock time; set it explicitly if you are calling the REST API directly. 428func (client ComputeNodeClient) Get(ctx context.Context, poolID string, nodeID string, selectParameter string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNode, err error) { 429 req, err := client.GetPreparer(ctx, poolID, nodeID, selectParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 430 if err != nil { 431 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Get", nil, "Failure preparing request") 432 return 433 } 434 435 resp, err := client.GetSender(req) 436 if err != nil { 437 result.Response = autorest.Response{Response: resp} 438 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Get", resp, "Failure sending request") 439 return 440 } 441 442 result, err = client.GetResponder(resp) 443 if err != nil { 444 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Get", resp, "Failure responding to request") 445 } 446 447 return 448} 449 450// GetPreparer prepares the Get request. 451func (client ComputeNodeClient) GetPreparer(ctx context.Context, poolID string, nodeID string, selectParameter string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 452 pathParameters := map[string]interface{}{ 453 "nodeId": autorest.Encode("path", nodeID), 454 "poolId": autorest.Encode("path", poolID), 455 } 456 457 const APIVersion = "2017-09-01.6.0" 458 queryParameters := map[string]interface{}{ 459 "api-version": APIVersion, 460 } 461 if len(selectParameter) > 0 { 462 queryParameters["$select"] = autorest.Encode("query", selectParameter) 463 } 464 if timeout != nil { 465 queryParameters["timeout"] = autorest.Encode("query", *timeout) 466 } else { 467 queryParameters["timeout"] = autorest.Encode("query", 30) 468 } 469 470 preparer := autorest.CreatePreparer( 471 autorest.AsGet(), 472 autorest.WithBaseURL(client.BaseURI), 473 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}", pathParameters), 474 autorest.WithQueryParameters(queryParameters)) 475 if clientRequestID != nil { 476 preparer = autorest.DecoratePreparer(preparer, 477 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 478 } 479 if returnClientRequestID != nil { 480 preparer = autorest.DecoratePreparer(preparer, 481 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 482 } else { 483 preparer = autorest.DecoratePreparer(preparer, 484 autorest.WithHeader("return-client-request-id", autorest.String(false))) 485 } 486 if ocpDate != nil { 487 preparer = autorest.DecoratePreparer(preparer, 488 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 489 } 490 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 491} 492 493// GetSender sends the Get request. The method will close the 494// http.Response Body if it receives an error. 495func (client ComputeNodeClient) GetSender(req *http.Request) (*http.Response, error) { 496 return autorest.SendWithSender(client, req, 497 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 498} 499 500// GetResponder handles the response to the Get request. The method always 501// closes the http.Response Body. 502func (client ComputeNodeClient) GetResponder(resp *http.Response) (result ComputeNode, err error) { 503 err = autorest.Respond( 504 resp, 505 client.ByInspecting(), 506 azure.WithErrorUnlessStatusCode(http.StatusOK), 507 autorest.ByUnmarshallingJSON(&result), 508 autorest.ByClosing()) 509 result.Response = autorest.Response{Response: resp} 510 return 511} 512 513// GetRemoteDesktop before you can access a node by using the RDP file, you must create a user account on the node. 514// This API can only be invoked on pools created with a cloud service configuration. For pools created with a virtual 515// machine configuration, see the GetRemoteLoginSettings API. 516// 517// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the compute node for which you 518// want to get the Remote Desktop Protocol file. timeout is the maximum time that the server can spend processing 519// the request, in seconds. The default is 30 seconds. clientRequestID is the caller-generated request identity, in 520// the form of a GUID with no decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 521// returnClientRequestID is whether the server should return the client-request-id in the response. ocpDate is the 522// time the request was issued. Client libraries typically set this to the current system clock time; set it 523// explicitly if you are calling the REST API directly. 524func (client ComputeNodeClient) GetRemoteDesktop(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ReadCloser, err error) { 525 req, err := client.GetRemoteDesktopPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate) 526 if err != nil { 527 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", nil, "Failure preparing request") 528 return 529 } 530 531 resp, err := client.GetRemoteDesktopSender(req) 532 if err != nil { 533 result.Response = autorest.Response{Response: resp} 534 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", resp, "Failure sending request") 535 return 536 } 537 538 result, err = client.GetRemoteDesktopResponder(resp) 539 if err != nil { 540 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", resp, "Failure responding to request") 541 } 542 543 return 544} 545 546// GetRemoteDesktopPreparer prepares the GetRemoteDesktop request. 547func (client ComputeNodeClient) GetRemoteDesktopPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 548 pathParameters := map[string]interface{}{ 549 "nodeId": autorest.Encode("path", nodeID), 550 "poolId": autorest.Encode("path", poolID), 551 } 552 553 const APIVersion = "2017-09-01.6.0" 554 queryParameters := map[string]interface{}{ 555 "api-version": APIVersion, 556 } 557 if timeout != nil { 558 queryParameters["timeout"] = autorest.Encode("query", *timeout) 559 } else { 560 queryParameters["timeout"] = autorest.Encode("query", 30) 561 } 562 563 preparer := autorest.CreatePreparer( 564 autorest.AsGet(), 565 autorest.WithBaseURL(client.BaseURI), 566 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/rdp", pathParameters), 567 autorest.WithQueryParameters(queryParameters)) 568 if clientRequestID != nil { 569 preparer = autorest.DecoratePreparer(preparer, 570 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 571 } 572 if returnClientRequestID != nil { 573 preparer = autorest.DecoratePreparer(preparer, 574 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 575 } else { 576 preparer = autorest.DecoratePreparer(preparer, 577 autorest.WithHeader("return-client-request-id", autorest.String(false))) 578 } 579 if ocpDate != nil { 580 preparer = autorest.DecoratePreparer(preparer, 581 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 582 } 583 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 584} 585 586// GetRemoteDesktopSender sends the GetRemoteDesktop request. The method will close the 587// http.Response Body if it receives an error. 588func (client ComputeNodeClient) GetRemoteDesktopSender(req *http.Request) (*http.Response, error) { 589 return autorest.SendWithSender(client, req, 590 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 591} 592 593// GetRemoteDesktopResponder handles the response to the GetRemoteDesktop request. The method always 594// closes the http.Response Body. 595func (client ComputeNodeClient) GetRemoteDesktopResponder(resp *http.Response) (result ReadCloser, err error) { 596 result.Value = &resp.Body 597 err = autorest.Respond( 598 resp, 599 client.ByInspecting(), 600 azure.WithErrorUnlessStatusCode(http.StatusOK)) 601 result.Response = autorest.Response{Response: resp} 602 return 603} 604 605// GetRemoteLoginSettings before you can remotely login to a node using the remote login settings, you must create a 606// user account on the node. This API can be invoked only on pools created with the virtual machine configuration 607// property. For pools created with a cloud service configuration, see the GetRemoteDesktop API. 608// 609// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the compute node for which to 610// obtain the remote login settings. timeout is the maximum time that the server can spend processing the request, 611// in seconds. The default is 30 seconds. clientRequestID is the caller-generated request identity, in the form of 612// a GUID with no decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID 613// is whether the server should return the client-request-id in the response. ocpDate is the time the request was 614// issued. Client libraries typically set this to the current system clock time; set it explicitly if you are 615// calling the REST API directly. 616func (client ComputeNodeClient) GetRemoteLoginSettings(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNodeGetRemoteLoginSettingsResult, err error) { 617 req, err := client.GetRemoteLoginSettingsPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate) 618 if err != nil { 619 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteLoginSettings", nil, "Failure preparing request") 620 return 621 } 622 623 resp, err := client.GetRemoteLoginSettingsSender(req) 624 if err != nil { 625 result.Response = autorest.Response{Response: resp} 626 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteLoginSettings", resp, "Failure sending request") 627 return 628 } 629 630 result, err = client.GetRemoteLoginSettingsResponder(resp) 631 if err != nil { 632 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteLoginSettings", resp, "Failure responding to request") 633 } 634 635 return 636} 637 638// GetRemoteLoginSettingsPreparer prepares the GetRemoteLoginSettings request. 639func (client ComputeNodeClient) GetRemoteLoginSettingsPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 640 pathParameters := map[string]interface{}{ 641 "nodeId": autorest.Encode("path", nodeID), 642 "poolId": autorest.Encode("path", poolID), 643 } 644 645 const APIVersion = "2017-09-01.6.0" 646 queryParameters := map[string]interface{}{ 647 "api-version": APIVersion, 648 } 649 if timeout != nil { 650 queryParameters["timeout"] = autorest.Encode("query", *timeout) 651 } else { 652 queryParameters["timeout"] = autorest.Encode("query", 30) 653 } 654 655 preparer := autorest.CreatePreparer( 656 autorest.AsGet(), 657 autorest.WithBaseURL(client.BaseURI), 658 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/remoteloginsettings", pathParameters), 659 autorest.WithQueryParameters(queryParameters)) 660 if clientRequestID != nil { 661 preparer = autorest.DecoratePreparer(preparer, 662 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 663 } 664 if returnClientRequestID != nil { 665 preparer = autorest.DecoratePreparer(preparer, 666 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 667 } else { 668 preparer = autorest.DecoratePreparer(preparer, 669 autorest.WithHeader("return-client-request-id", autorest.String(false))) 670 } 671 if ocpDate != nil { 672 preparer = autorest.DecoratePreparer(preparer, 673 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 674 } 675 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 676} 677 678// GetRemoteLoginSettingsSender sends the GetRemoteLoginSettings request. The method will close the 679// http.Response Body if it receives an error. 680func (client ComputeNodeClient) GetRemoteLoginSettingsSender(req *http.Request) (*http.Response, error) { 681 return autorest.SendWithSender(client, req, 682 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 683} 684 685// GetRemoteLoginSettingsResponder handles the response to the GetRemoteLoginSettings request. The method always 686// closes the http.Response Body. 687func (client ComputeNodeClient) GetRemoteLoginSettingsResponder(resp *http.Response) (result ComputeNodeGetRemoteLoginSettingsResult, err error) { 688 err = autorest.Respond( 689 resp, 690 client.ByInspecting(), 691 azure.WithErrorUnlessStatusCode(http.StatusOK), 692 autorest.ByUnmarshallingJSON(&result), 693 autorest.ByClosing()) 694 result.Response = autorest.Response{Response: resp} 695 return 696} 697 698// List sends the list request. 699// 700// poolID is the ID of the pool from which you want to list nodes. filter is an OData $filter clause. For more 701// information on constructing this filter, see 702// https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-nodes-in-a-pool. 703// selectParameter is an OData $select clause. maxResults is the maximum number of items to return in the response. 704// A maximum of 1000 nodes can be returned. timeout is the maximum time that the server can spend processing the 705// request, in seconds. The default is 30 seconds. clientRequestID is the caller-generated request identity, in the 706// form of a GUID with no decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 707// returnClientRequestID is whether the server should return the client-request-id in the response. ocpDate is the 708// time the request was issued. Client libraries typically set this to the current system clock time; set it 709// explicitly if you are calling the REST API directly. 710func (client ComputeNodeClient) List(ctx context.Context, poolID string, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNodeListResultPage, err error) { 711 if err := validation.Validate([]validation.Validation{ 712 {TargetValue: maxResults, 713 Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false, 714 Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil}, 715 {Target: "maxResults", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, 716 }}}}}); err != nil { 717 return result, validation.NewError("batch.ComputeNodeClient", "List", err.Error()) 718 } 719 720 result.fn = client.listNextResults 721 req, err := client.ListPreparer(ctx, poolID, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 722 if err != nil { 723 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", nil, "Failure preparing request") 724 return 725 } 726 727 resp, err := client.ListSender(req) 728 if err != nil { 729 result.cnlr.Response = autorest.Response{Response: resp} 730 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", resp, "Failure sending request") 731 return 732 } 733 734 result.cnlr, err = client.ListResponder(resp) 735 if err != nil { 736 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", resp, "Failure responding to request") 737 } 738 739 return 740} 741 742// ListPreparer prepares the List request. 743func (client ComputeNodeClient) ListPreparer(ctx context.Context, poolID string, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 744 pathParameters := map[string]interface{}{ 745 "poolId": autorest.Encode("path", poolID), 746 } 747 748 const APIVersion = "2017-09-01.6.0" 749 queryParameters := map[string]interface{}{ 750 "api-version": APIVersion, 751 } 752 if len(filter) > 0 { 753 queryParameters["$filter"] = autorest.Encode("query", filter) 754 } 755 if len(selectParameter) > 0 { 756 queryParameters["$select"] = autorest.Encode("query", selectParameter) 757 } 758 if maxResults != nil { 759 queryParameters["maxresults"] = autorest.Encode("query", *maxResults) 760 } else { 761 queryParameters["maxresults"] = autorest.Encode("query", 1000) 762 } 763 if timeout != nil { 764 queryParameters["timeout"] = autorest.Encode("query", *timeout) 765 } else { 766 queryParameters["timeout"] = autorest.Encode("query", 30) 767 } 768 769 preparer := autorest.CreatePreparer( 770 autorest.AsGet(), 771 autorest.WithBaseURL(client.BaseURI), 772 autorest.WithPathParameters("/pools/{poolId}/nodes", pathParameters), 773 autorest.WithQueryParameters(queryParameters)) 774 if clientRequestID != nil { 775 preparer = autorest.DecoratePreparer(preparer, 776 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 777 } 778 if returnClientRequestID != nil { 779 preparer = autorest.DecoratePreparer(preparer, 780 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 781 } else { 782 preparer = autorest.DecoratePreparer(preparer, 783 autorest.WithHeader("return-client-request-id", autorest.String(false))) 784 } 785 if ocpDate != nil { 786 preparer = autorest.DecoratePreparer(preparer, 787 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 788 } 789 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 790} 791 792// ListSender sends the List request. The method will close the 793// http.Response Body if it receives an error. 794func (client ComputeNodeClient) ListSender(req *http.Request) (*http.Response, error) { 795 return autorest.SendWithSender(client, req, 796 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 797} 798 799// ListResponder handles the response to the List request. The method always 800// closes the http.Response Body. 801func (client ComputeNodeClient) ListResponder(resp *http.Response) (result ComputeNodeListResult, err error) { 802 err = autorest.Respond( 803 resp, 804 client.ByInspecting(), 805 azure.WithErrorUnlessStatusCode(http.StatusOK), 806 autorest.ByUnmarshallingJSON(&result), 807 autorest.ByClosing()) 808 result.Response = autorest.Response{Response: resp} 809 return 810} 811 812// listNextResults retrieves the next set of results, if any. 813func (client ComputeNodeClient) listNextResults(lastResults ComputeNodeListResult) (result ComputeNodeListResult, err error) { 814 req, err := lastResults.computeNodeListResultPreparer() 815 if err != nil { 816 return result, autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", nil, "Failure preparing next results request") 817 } 818 if req == nil { 819 return 820 } 821 resp, err := client.ListSender(req) 822 if err != nil { 823 result.Response = autorest.Response{Response: resp} 824 return result, autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", resp, "Failure sending next results request") 825 } 826 result, err = client.ListResponder(resp) 827 if err != nil { 828 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", resp, "Failure responding to next results request") 829 } 830 return 831} 832 833// ListComplete enumerates all values, automatically crossing page boundaries as required. 834func (client ComputeNodeClient) ListComplete(ctx context.Context, poolID string, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNodeListResultIterator, err error) { 835 result.page, err = client.List(ctx, poolID, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 836 return 837} 838 839// Reboot you can restart a node only if it is in an idle or running state. 840// 841// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the compute node that you want 842// to restart. nodeRebootParameter is the parameters for the request. timeout is the maximum time that the server 843// can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is the caller-generated 844// request identity, in the form of a GUID with no decoration such as curly braces, e.g. 845// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the 846// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set 847// this to the current system clock time; set it explicitly if you are calling the REST API directly. 848func (client ComputeNodeClient) Reboot(ctx context.Context, poolID string, nodeID string, nodeRebootParameter *NodeRebootParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 849 req, err := client.RebootPreparer(ctx, poolID, nodeID, nodeRebootParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 850 if err != nil { 851 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", nil, "Failure preparing request") 852 return 853 } 854 855 resp, err := client.RebootSender(req) 856 if err != nil { 857 result.Response = resp 858 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", resp, "Failure sending request") 859 return 860 } 861 862 result, err = client.RebootResponder(resp) 863 if err != nil { 864 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", resp, "Failure responding to request") 865 } 866 867 return 868} 869 870// RebootPreparer prepares the Reboot request. 871func (client ComputeNodeClient) RebootPreparer(ctx context.Context, poolID string, nodeID string, nodeRebootParameter *NodeRebootParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 872 pathParameters := map[string]interface{}{ 873 "nodeId": autorest.Encode("path", nodeID), 874 "poolId": autorest.Encode("path", poolID), 875 } 876 877 const APIVersion = "2017-09-01.6.0" 878 queryParameters := map[string]interface{}{ 879 "api-version": APIVersion, 880 } 881 if timeout != nil { 882 queryParameters["timeout"] = autorest.Encode("query", *timeout) 883 } else { 884 queryParameters["timeout"] = autorest.Encode("query", 30) 885 } 886 887 preparer := autorest.CreatePreparer( 888 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 889 autorest.AsPost(), 890 autorest.WithBaseURL(client.BaseURI), 891 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/reboot", pathParameters), 892 autorest.WithQueryParameters(queryParameters)) 893 if nodeRebootParameter != nil { 894 preparer = autorest.DecoratePreparer(preparer, 895 autorest.WithJSON(nodeRebootParameter)) 896 } 897 if clientRequestID != nil { 898 preparer = autorest.DecoratePreparer(preparer, 899 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 900 } 901 if returnClientRequestID != nil { 902 preparer = autorest.DecoratePreparer(preparer, 903 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 904 } else { 905 preparer = autorest.DecoratePreparer(preparer, 906 autorest.WithHeader("return-client-request-id", autorest.String(false))) 907 } 908 if ocpDate != nil { 909 preparer = autorest.DecoratePreparer(preparer, 910 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 911 } 912 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 913} 914 915// RebootSender sends the Reboot request. The method will close the 916// http.Response Body if it receives an error. 917func (client ComputeNodeClient) RebootSender(req *http.Request) (*http.Response, error) { 918 return autorest.SendWithSender(client, req, 919 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 920} 921 922// RebootResponder handles the response to the Reboot request. The method always 923// closes the http.Response Body. 924func (client ComputeNodeClient) RebootResponder(resp *http.Response) (result autorest.Response, err error) { 925 err = autorest.Respond( 926 resp, 927 client.ByInspecting(), 928 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 929 autorest.ByClosing()) 930 result.Response = resp 931 return 932} 933 934// Reimage you can reinstall the operating system on a node only if it is in an idle or running state. This API can be 935// invoked only on pools created with the cloud service configuration property. 936// 937// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the compute node that you want 938// to restart. nodeReimageParameter is the parameters for the request. timeout is the maximum time that the server 939// can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is the caller-generated 940// request identity, in the form of a GUID with no decoration such as curly braces, e.g. 941// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the 942// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set 943// this to the current system clock time; set it explicitly if you are calling the REST API directly. 944func (client ComputeNodeClient) Reimage(ctx context.Context, poolID string, nodeID string, nodeReimageParameter *NodeReimageParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 945 req, err := client.ReimagePreparer(ctx, poolID, nodeID, nodeReimageParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 946 if err != nil { 947 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", nil, "Failure preparing request") 948 return 949 } 950 951 resp, err := client.ReimageSender(req) 952 if err != nil { 953 result.Response = resp 954 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", resp, "Failure sending request") 955 return 956 } 957 958 result, err = client.ReimageResponder(resp) 959 if err != nil { 960 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", resp, "Failure responding to request") 961 } 962 963 return 964} 965 966// ReimagePreparer prepares the Reimage request. 967func (client ComputeNodeClient) ReimagePreparer(ctx context.Context, poolID string, nodeID string, nodeReimageParameter *NodeReimageParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 968 pathParameters := map[string]interface{}{ 969 "nodeId": autorest.Encode("path", nodeID), 970 "poolId": autorest.Encode("path", poolID), 971 } 972 973 const APIVersion = "2017-09-01.6.0" 974 queryParameters := map[string]interface{}{ 975 "api-version": APIVersion, 976 } 977 if timeout != nil { 978 queryParameters["timeout"] = autorest.Encode("query", *timeout) 979 } else { 980 queryParameters["timeout"] = autorest.Encode("query", 30) 981 } 982 983 preparer := autorest.CreatePreparer( 984 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 985 autorest.AsPost(), 986 autorest.WithBaseURL(client.BaseURI), 987 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/reimage", pathParameters), 988 autorest.WithQueryParameters(queryParameters)) 989 if nodeReimageParameter != nil { 990 preparer = autorest.DecoratePreparer(preparer, 991 autorest.WithJSON(nodeReimageParameter)) 992 } 993 if clientRequestID != nil { 994 preparer = autorest.DecoratePreparer(preparer, 995 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 996 } 997 if returnClientRequestID != nil { 998 preparer = autorest.DecoratePreparer(preparer, 999 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1000 } else { 1001 preparer = autorest.DecoratePreparer(preparer, 1002 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1003 } 1004 if ocpDate != nil { 1005 preparer = autorest.DecoratePreparer(preparer, 1006 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1007 } 1008 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1009} 1010 1011// ReimageSender sends the Reimage request. The method will close the 1012// http.Response Body if it receives an error. 1013func (client ComputeNodeClient) ReimageSender(req *http.Request) (*http.Response, error) { 1014 return autorest.SendWithSender(client, req, 1015 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1016} 1017 1018// ReimageResponder handles the response to the Reimage request. The method always 1019// closes the http.Response Body. 1020func (client ComputeNodeClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) { 1021 err = autorest.Respond( 1022 resp, 1023 client.ByInspecting(), 1024 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1025 autorest.ByClosing()) 1026 result.Response = resp 1027 return 1028} 1029 1030// UpdateUser this operation replaces of all the updateable properties of the account. For example, if the expiryTime 1031// element is not specified, the current value is replaced with the default value, not left unmodified. You can update 1032// a user account on a node only when it is in the idle or running state. 1033// 1034// poolID is the ID of the pool that contains the compute node. nodeID is the ID of the machine on which you want 1035// to update a user account. userName is the name of the user account to update. nodeUpdateUserParameter is the 1036// parameters for the request. timeout is the maximum time that the server can spend processing the request, in 1037// seconds. The default is 30 seconds. clientRequestID is the caller-generated request identity, in the form of a 1038// GUID with no decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID 1039// is whether the server should return the client-request-id in the response. ocpDate is the time the request was 1040// issued. Client libraries typically set this to the current system clock time; set it explicitly if you are 1041// calling the REST API directly. 1042func (client ComputeNodeClient) UpdateUser(ctx context.Context, poolID string, nodeID string, userName string, nodeUpdateUserParameter NodeUpdateUserParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 1043 req, err := client.UpdateUserPreparer(ctx, poolID, nodeID, userName, nodeUpdateUserParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 1044 if err != nil { 1045 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", nil, "Failure preparing request") 1046 return 1047 } 1048 1049 resp, err := client.UpdateUserSender(req) 1050 if err != nil { 1051 result.Response = resp 1052 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", resp, "Failure sending request") 1053 return 1054 } 1055 1056 result, err = client.UpdateUserResponder(resp) 1057 if err != nil { 1058 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", resp, "Failure responding to request") 1059 } 1060 1061 return 1062} 1063 1064// UpdateUserPreparer prepares the UpdateUser request. 1065func (client ComputeNodeClient) UpdateUserPreparer(ctx context.Context, poolID string, nodeID string, userName string, nodeUpdateUserParameter NodeUpdateUserParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 1066 pathParameters := map[string]interface{}{ 1067 "nodeId": autorest.Encode("path", nodeID), 1068 "poolId": autorest.Encode("path", poolID), 1069 "userName": autorest.Encode("path", userName), 1070 } 1071 1072 const APIVersion = "2017-09-01.6.0" 1073 queryParameters := map[string]interface{}{ 1074 "api-version": APIVersion, 1075 } 1076 if timeout != nil { 1077 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1078 } else { 1079 queryParameters["timeout"] = autorest.Encode("query", 30) 1080 } 1081 1082 preparer := autorest.CreatePreparer( 1083 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 1084 autorest.AsPut(), 1085 autorest.WithBaseURL(client.BaseURI), 1086 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/users/{userName}", pathParameters), 1087 autorest.WithJSON(nodeUpdateUserParameter), 1088 autorest.WithQueryParameters(queryParameters)) 1089 if clientRequestID != nil { 1090 preparer = autorest.DecoratePreparer(preparer, 1091 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1092 } 1093 if returnClientRequestID != nil { 1094 preparer = autorest.DecoratePreparer(preparer, 1095 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1096 } else { 1097 preparer = autorest.DecoratePreparer(preparer, 1098 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1099 } 1100 if ocpDate != nil { 1101 preparer = autorest.DecoratePreparer(preparer, 1102 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1103 } 1104 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1105} 1106 1107// UpdateUserSender sends the UpdateUser request. The method will close the 1108// http.Response Body if it receives an error. 1109func (client ComputeNodeClient) UpdateUserSender(req *http.Request) (*http.Response, error) { 1110 return autorest.SendWithSender(client, req, 1111 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1112} 1113 1114// UpdateUserResponder handles the response to the UpdateUser request. The method always 1115// closes the http.Response Body. 1116func (client ComputeNodeClient) UpdateUserResponder(resp *http.Response) (result autorest.Response, err error) { 1117 err = autorest.Respond( 1118 resp, 1119 client.ByInspecting(), 1120 azure.WithErrorUnlessStatusCode(http.StatusOK), 1121 autorest.ByClosing()) 1122 result.Response = resp 1123 return 1124} 1125