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 "net/http" 27) 28 29// ComputeNodeClient is the a client for issuing REST requests to the Azure Batch service. 30type ComputeNodeClient struct { 31 BaseClient 32} 33 34// NewComputeNodeClient creates an instance of the ComputeNodeClient client. 35func NewComputeNodeClient() ComputeNodeClient { 36 return NewComputeNodeClientWithBaseURI(DefaultBaseURI) 37} 38 39// NewComputeNodeClientWithBaseURI creates an instance of the ComputeNodeClient client. 40func NewComputeNodeClientWithBaseURI(baseURI string) ComputeNodeClient { 41 return ComputeNodeClient{NewWithBaseURI(baseURI)} 42} 43 44// AddUser adds a user account to the specified compute node. 45// 46// poolID is the id of the pool that contains the compute node. nodeID is the id of the machine on which you want 47// to create a user account. userParameter is specifies the user account to be created. timeout is sets the maximum 48// time that the server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is 49// caller generated request identity, in the form of a GUID with no decoration such as curly braces e.g. 50// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return the 51// client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified, this 52// header will be automatically populated with the current system clock time. 53func (client ComputeNodeClient) AddUser(ctx context.Context, poolID string, nodeID string, userParameter ComputeNodeUser, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 54 if err := validation.Validate([]validation.Validation{ 55 {TargetValue: userParameter, 56 Constraints: []validation.Constraint{{Target: "userParameter.Name", Name: validation.Null, Rule: true, Chain: nil}, 57 {Target: "userParameter.Password", 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 string, 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 = "2015-12-01.2.2" 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.AsJSON(), 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 len(clientRequestID) > 0 { 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 } 114 if ocpDate != nil { 115 preparer = autorest.DecoratePreparer(preparer, 116 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 117 } 118 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 119} 120 121// AddUserSender sends the AddUser request. The method will close the 122// http.Response Body if it receives an error. 123func (client ComputeNodeClient) AddUserSender(req *http.Request) (*http.Response, error) { 124 return autorest.SendWithSender(client, req, 125 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 126} 127 128// AddUserResponder handles the response to the AddUser request. The method always 129// closes the http.Response Body. 130func (client ComputeNodeClient) AddUserResponder(resp *http.Response) (result autorest.Response, err error) { 131 err = autorest.Respond( 132 resp, 133 client.ByInspecting(), 134 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 135 autorest.ByClosing()) 136 result.Response = resp 137 return 138} 139 140// DeleteUser deletes a user account from the specified compute node. 141// 142// poolID is the id of the pool that contains the compute node. nodeID is the id of the machine on which you want 143// to delete a user account. userName is the name of the user account to delete. timeout is sets the maximum time 144// that the server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is 145// caller generated request identity, in the form of a GUID with no decoration such as curly braces e.g. 146// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return the 147// client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified, this 148// header will be automatically populated with the current system clock time. 149func (client ComputeNodeClient) DeleteUser(ctx context.Context, poolID string, nodeID string, userName string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 150 req, err := client.DeleteUserPreparer(ctx, poolID, nodeID, userName, timeout, clientRequestID, returnClientRequestID, ocpDate) 151 if err != nil { 152 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DeleteUser", nil, "Failure preparing request") 153 return 154 } 155 156 resp, err := client.DeleteUserSender(req) 157 if err != nil { 158 result.Response = resp 159 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DeleteUser", resp, "Failure sending request") 160 return 161 } 162 163 result, err = client.DeleteUserResponder(resp) 164 if err != nil { 165 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DeleteUser", resp, "Failure responding to request") 166 } 167 168 return 169} 170 171// DeleteUserPreparer prepares the DeleteUser request. 172func (client ComputeNodeClient) DeleteUserPreparer(ctx context.Context, poolID string, nodeID string, userName string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 173 pathParameters := map[string]interface{}{ 174 "nodeId": autorest.Encode("path", nodeID), 175 "poolId": autorest.Encode("path", poolID), 176 "userName": autorest.Encode("path", userName), 177 } 178 179 const APIVersion = "2015-12-01.2.2" 180 queryParameters := map[string]interface{}{ 181 "api-version": APIVersion, 182 } 183 if timeout != nil { 184 queryParameters["timeout"] = autorest.Encode("query", *timeout) 185 } else { 186 queryParameters["timeout"] = autorest.Encode("query", 30) 187 } 188 189 preparer := autorest.CreatePreparer( 190 autorest.AsDelete(), 191 autorest.WithBaseURL(client.BaseURI), 192 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/users/{userName}", pathParameters), 193 autorest.WithQueryParameters(queryParameters)) 194 if len(clientRequestID) > 0 { 195 preparer = autorest.DecoratePreparer(preparer, 196 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 197 } 198 if returnClientRequestID != nil { 199 preparer = autorest.DecoratePreparer(preparer, 200 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 201 } 202 if ocpDate != nil { 203 preparer = autorest.DecoratePreparer(preparer, 204 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 205 } 206 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 207} 208 209// DeleteUserSender sends the DeleteUser request. The method will close the 210// http.Response Body if it receives an error. 211func (client ComputeNodeClient) DeleteUserSender(req *http.Request) (*http.Response, error) { 212 return autorest.SendWithSender(client, req, 213 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 214} 215 216// DeleteUserResponder handles the response to the DeleteUser request. The method always 217// closes the http.Response Body. 218func (client ComputeNodeClient) DeleteUserResponder(resp *http.Response) (result autorest.Response, err error) { 219 err = autorest.Respond( 220 resp, 221 client.ByInspecting(), 222 azure.WithErrorUnlessStatusCode(http.StatusOK), 223 autorest.ByClosing()) 224 result.Response = resp 225 return 226} 227 228// DisableScheduling disable task scheduling of the specified compute node. 229// 230// poolID is the id of the pool that contains the compute node. nodeID is the id of the compute node that you want 231// to disable task scheduling. nodeDisableSchedulingParameter is the parameters for the request. timeout is sets 232// the maximum time that the server can spend processing the request, in seconds. The default is 30 seconds. 233// clientRequestID is caller generated request identity, in the form of a GUID with no decoration such as curly 234// braces e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return 235// the client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified, 236// this header will be automatically populated with the current system clock time. 237func (client ComputeNodeClient) DisableScheduling(ctx context.Context, poolID string, nodeID string, nodeDisableSchedulingParameter *NodeDisableSchedulingParameter, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 238 req, err := client.DisableSchedulingPreparer(ctx, poolID, nodeID, nodeDisableSchedulingParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 239 if err != nil { 240 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DisableScheduling", nil, "Failure preparing request") 241 return 242 } 243 244 resp, err := client.DisableSchedulingSender(req) 245 if err != nil { 246 result.Response = resp 247 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DisableScheduling", resp, "Failure sending request") 248 return 249 } 250 251 result, err = client.DisableSchedulingResponder(resp) 252 if err != nil { 253 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DisableScheduling", resp, "Failure responding to request") 254 } 255 256 return 257} 258 259// DisableSchedulingPreparer prepares the DisableScheduling request. 260func (client ComputeNodeClient) DisableSchedulingPreparer(ctx context.Context, poolID string, nodeID string, nodeDisableSchedulingParameter *NodeDisableSchedulingParameter, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 261 pathParameters := map[string]interface{}{ 262 "nodeId": autorest.Encode("path", nodeID), 263 "poolId": autorest.Encode("path", poolID), 264 } 265 266 const APIVersion = "2015-12-01.2.2" 267 queryParameters := map[string]interface{}{ 268 "api-version": APIVersion, 269 } 270 if timeout != nil { 271 queryParameters["timeout"] = autorest.Encode("query", *timeout) 272 } else { 273 queryParameters["timeout"] = autorest.Encode("query", 30) 274 } 275 276 preparer := autorest.CreatePreparer( 277 autorest.AsJSON(), 278 autorest.AsPost(), 279 autorest.WithBaseURL(client.BaseURI), 280 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/disablescheduling", pathParameters), 281 autorest.WithQueryParameters(queryParameters)) 282 if nodeDisableSchedulingParameter != nil { 283 preparer = autorest.DecoratePreparer(preparer, 284 autorest.WithJSON(nodeDisableSchedulingParameter)) 285 } 286 if len(clientRequestID) > 0 { 287 preparer = autorest.DecoratePreparer(preparer, 288 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 289 } 290 if returnClientRequestID != nil { 291 preparer = autorest.DecoratePreparer(preparer, 292 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 293 } 294 if ocpDate != nil { 295 preparer = autorest.DecoratePreparer(preparer, 296 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 297 } 298 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 299} 300 301// DisableSchedulingSender sends the DisableScheduling request. The method will close the 302// http.Response Body if it receives an error. 303func (client ComputeNodeClient) DisableSchedulingSender(req *http.Request) (*http.Response, error) { 304 return autorest.SendWithSender(client, req, 305 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 306} 307 308// DisableSchedulingResponder handles the response to the DisableScheduling request. The method always 309// closes the http.Response Body. 310func (client ComputeNodeClient) DisableSchedulingResponder(resp *http.Response) (result autorest.Response, err error) { 311 err = autorest.Respond( 312 resp, 313 client.ByInspecting(), 314 azure.WithErrorUnlessStatusCode(http.StatusOK), 315 autorest.ByClosing()) 316 result.Response = resp 317 return 318} 319 320// EnableScheduling enable task scheduling of the specified compute node. 321// 322// poolID is the id of the pool that contains the compute node. nodeID is the id of the compute node that you want 323// to enable task scheduling. timeout is sets the maximum time that the server can spend processing the request, in 324// seconds. The default is 30 seconds. clientRequestID is caller generated request identity, in the form of a GUID 325// with no decoration such as curly braces e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is 326// specifies if the server should return the client-request-id identifier in the response. ocpDate is the time the 327// request was issued. If not specified, this header will be automatically populated with the current system clock 328// time. 329func (client ComputeNodeClient) EnableScheduling(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 330 req, err := client.EnableSchedulingPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate) 331 if err != nil { 332 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "EnableScheduling", nil, "Failure preparing request") 333 return 334 } 335 336 resp, err := client.EnableSchedulingSender(req) 337 if err != nil { 338 result.Response = resp 339 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "EnableScheduling", resp, "Failure sending request") 340 return 341 } 342 343 result, err = client.EnableSchedulingResponder(resp) 344 if err != nil { 345 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "EnableScheduling", resp, "Failure responding to request") 346 } 347 348 return 349} 350 351// EnableSchedulingPreparer prepares the EnableScheduling request. 352func (client ComputeNodeClient) EnableSchedulingPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 353 pathParameters := map[string]interface{}{ 354 "nodeId": autorest.Encode("path", nodeID), 355 "poolId": autorest.Encode("path", poolID), 356 } 357 358 const APIVersion = "2015-12-01.2.2" 359 queryParameters := map[string]interface{}{ 360 "api-version": APIVersion, 361 } 362 if timeout != nil { 363 queryParameters["timeout"] = autorest.Encode("query", *timeout) 364 } else { 365 queryParameters["timeout"] = autorest.Encode("query", 30) 366 } 367 368 preparer := autorest.CreatePreparer( 369 autorest.AsPost(), 370 autorest.WithBaseURL(client.BaseURI), 371 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/enablescheduling", pathParameters), 372 autorest.WithQueryParameters(queryParameters)) 373 if len(clientRequestID) > 0 { 374 preparer = autorest.DecoratePreparer(preparer, 375 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 376 } 377 if returnClientRequestID != nil { 378 preparer = autorest.DecoratePreparer(preparer, 379 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 380 } 381 if ocpDate != nil { 382 preparer = autorest.DecoratePreparer(preparer, 383 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 384 } 385 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 386} 387 388// EnableSchedulingSender sends the EnableScheduling request. The method will close the 389// http.Response Body if it receives an error. 390func (client ComputeNodeClient) EnableSchedulingSender(req *http.Request) (*http.Response, error) { 391 return autorest.SendWithSender(client, req, 392 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 393} 394 395// EnableSchedulingResponder handles the response to the EnableScheduling request. The method always 396// closes the http.Response Body. 397func (client ComputeNodeClient) EnableSchedulingResponder(resp *http.Response) (result autorest.Response, err error) { 398 err = autorest.Respond( 399 resp, 400 client.ByInspecting(), 401 azure.WithErrorUnlessStatusCode(http.StatusOK), 402 autorest.ByClosing()) 403 result.Response = resp 404 return 405} 406 407// Get gets information about the specified compute node. 408// 409// poolID is the id of the pool that contains the compute node. nodeID is the id of the compute node that you want 410// to get information about. selectParameter is sets an OData $select clause. timeout is sets the maximum time that 411// the server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is caller 412// generated request identity, in the form of a GUID with no decoration such as curly braces e.g. 413// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return the 414// client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified, this 415// header will be automatically populated with the current system clock time. 416func (client ComputeNodeClient) Get(ctx context.Context, poolID string, nodeID string, selectParameter string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNode, err error) { 417 req, err := client.GetPreparer(ctx, poolID, nodeID, selectParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 418 if err != nil { 419 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Get", nil, "Failure preparing request") 420 return 421 } 422 423 resp, err := client.GetSender(req) 424 if err != nil { 425 result.Response = autorest.Response{Response: resp} 426 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Get", resp, "Failure sending request") 427 return 428 } 429 430 result, err = client.GetResponder(resp) 431 if err != nil { 432 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Get", resp, "Failure responding to request") 433 } 434 435 return 436} 437 438// GetPreparer prepares the Get request. 439func (client ComputeNodeClient) GetPreparer(ctx context.Context, poolID string, nodeID string, selectParameter string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 440 pathParameters := map[string]interface{}{ 441 "nodeId": autorest.Encode("path", nodeID), 442 "poolId": autorest.Encode("path", poolID), 443 } 444 445 const APIVersion = "2015-12-01.2.2" 446 queryParameters := map[string]interface{}{ 447 "api-version": APIVersion, 448 } 449 if len(selectParameter) > 0 { 450 queryParameters["$select"] = autorest.Encode("query", selectParameter) 451 } 452 if timeout != nil { 453 queryParameters["timeout"] = autorest.Encode("query", *timeout) 454 } else { 455 queryParameters["timeout"] = autorest.Encode("query", 30) 456 } 457 458 preparer := autorest.CreatePreparer( 459 autorest.AsGet(), 460 autorest.WithBaseURL(client.BaseURI), 461 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}", pathParameters), 462 autorest.WithQueryParameters(queryParameters)) 463 if len(clientRequestID) > 0 { 464 preparer = autorest.DecoratePreparer(preparer, 465 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 466 } 467 if returnClientRequestID != nil { 468 preparer = autorest.DecoratePreparer(preparer, 469 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 470 } 471 if ocpDate != nil { 472 preparer = autorest.DecoratePreparer(preparer, 473 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 474 } 475 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 476} 477 478// GetSender sends the Get request. The method will close the 479// http.Response Body if it receives an error. 480func (client ComputeNodeClient) GetSender(req *http.Request) (*http.Response, error) { 481 return autorest.SendWithSender(client, req, 482 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 483} 484 485// GetResponder handles the response to the Get request. The method always 486// closes the http.Response Body. 487func (client ComputeNodeClient) GetResponder(resp *http.Response) (result ComputeNode, err error) { 488 err = autorest.Respond( 489 resp, 490 client.ByInspecting(), 491 azure.WithErrorUnlessStatusCode(http.StatusOK), 492 autorest.ByUnmarshallingJSON(&result), 493 autorest.ByClosing()) 494 result.Response = autorest.Response{Response: resp} 495 return 496} 497 498// GetRemoteDesktop gets the Remote Desktop Protocol file for the specified compute node. 499// 500// poolID is the id of the pool that contains the compute node. nodeID is the id of the compute node for which you 501// want to get the Remote Desktop Protocol file. timeout is sets the maximum time that the server can spend 502// processing the request, in seconds. The default is 30 seconds. clientRequestID is caller generated request 503// identity, in the form of a GUID with no decoration such as curly braces e.g. 504// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return the 505// client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified, this 506// header will be automatically populated with the current system clock time. 507func (client ComputeNodeClient) GetRemoteDesktop(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ReadCloser, err error) { 508 req, err := client.GetRemoteDesktopPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate) 509 if err != nil { 510 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", nil, "Failure preparing request") 511 return 512 } 513 514 resp, err := client.GetRemoteDesktopSender(req) 515 if err != nil { 516 result.Response = autorest.Response{Response: resp} 517 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", resp, "Failure sending request") 518 return 519 } 520 521 result, err = client.GetRemoteDesktopResponder(resp) 522 if err != nil { 523 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", resp, "Failure responding to request") 524 } 525 526 return 527} 528 529// GetRemoteDesktopPreparer prepares the GetRemoteDesktop request. 530func (client ComputeNodeClient) GetRemoteDesktopPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 531 pathParameters := map[string]interface{}{ 532 "nodeId": autorest.Encode("path", nodeID), 533 "poolId": autorest.Encode("path", poolID), 534 } 535 536 const APIVersion = "2015-12-01.2.2" 537 queryParameters := map[string]interface{}{ 538 "api-version": APIVersion, 539 } 540 if timeout != nil { 541 queryParameters["timeout"] = autorest.Encode("query", *timeout) 542 } else { 543 queryParameters["timeout"] = autorest.Encode("query", 30) 544 } 545 546 preparer := autorest.CreatePreparer( 547 autorest.AsGet(), 548 autorest.WithBaseURL(client.BaseURI), 549 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/rdp", pathParameters), 550 autorest.WithQueryParameters(queryParameters)) 551 if len(clientRequestID) > 0 { 552 preparer = autorest.DecoratePreparer(preparer, 553 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 554 } 555 if returnClientRequestID != nil { 556 preparer = autorest.DecoratePreparer(preparer, 557 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 558 } 559 if ocpDate != nil { 560 preparer = autorest.DecoratePreparer(preparer, 561 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 562 } 563 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 564} 565 566// GetRemoteDesktopSender sends the GetRemoteDesktop request. The method will close the 567// http.Response Body if it receives an error. 568func (client ComputeNodeClient) GetRemoteDesktopSender(req *http.Request) (*http.Response, error) { 569 return autorest.SendWithSender(client, req, 570 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 571} 572 573// GetRemoteDesktopResponder handles the response to the GetRemoteDesktop request. The method always 574// closes the http.Response Body. 575func (client ComputeNodeClient) GetRemoteDesktopResponder(resp *http.Response) (result ReadCloser, err error) { 576 result.Value = &resp.Body 577 err = autorest.Respond( 578 resp, 579 client.ByInspecting(), 580 azure.WithErrorUnlessStatusCode(http.StatusOK)) 581 result.Response = autorest.Response{Response: resp} 582 return 583} 584 585// List lists the compute nodes in the specified pool. 586// 587// poolID is the id of the pool from which you want to list nodes. filter is sets an OData $filter clause. 588// selectParameter is sets an OData $select clause. maxResults is sets the maximum number of items to return in the 589// response. timeout is sets the maximum time that the server can spend processing the request, in seconds. The 590// default is 30 seconds. clientRequestID is caller generated request identity, in the form of a GUID with no 591// decoration such as curly braces e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if 592// the server should return the client-request-id identifier in the response. ocpDate is the time the request was 593// issued. If not specified, this header will be automatically populated with the current system clock time. 594func (client ComputeNodeClient) List(ctx context.Context, poolID string, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNodeListResultPage, err error) { 595 result.fn = client.listNextResults 596 req, err := client.ListPreparer(ctx, poolID, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 597 if err != nil { 598 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", nil, "Failure preparing request") 599 return 600 } 601 602 resp, err := client.ListSender(req) 603 if err != nil { 604 result.cnlr.Response = autorest.Response{Response: resp} 605 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", resp, "Failure sending request") 606 return 607 } 608 609 result.cnlr, err = client.ListResponder(resp) 610 if err != nil { 611 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", resp, "Failure responding to request") 612 } 613 614 return 615} 616 617// ListPreparer prepares the List request. 618func (client ComputeNodeClient) ListPreparer(ctx context.Context, poolID string, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 619 pathParameters := map[string]interface{}{ 620 "poolId": autorest.Encode("path", poolID), 621 } 622 623 const APIVersion = "2015-12-01.2.2" 624 queryParameters := map[string]interface{}{ 625 "api-version": APIVersion, 626 } 627 if len(filter) > 0 { 628 queryParameters["$filter"] = autorest.Encode("query", filter) 629 } 630 if len(selectParameter) > 0 { 631 queryParameters["$select"] = autorest.Encode("query", selectParameter) 632 } 633 if maxResults != nil { 634 queryParameters["maxresults"] = autorest.Encode("query", *maxResults) 635 } 636 if timeout != nil { 637 queryParameters["timeout"] = autorest.Encode("query", *timeout) 638 } else { 639 queryParameters["timeout"] = autorest.Encode("query", 30) 640 } 641 642 preparer := autorest.CreatePreparer( 643 autorest.AsGet(), 644 autorest.WithBaseURL(client.BaseURI), 645 autorest.WithPathParameters("/pools/{poolId}/nodes", pathParameters), 646 autorest.WithQueryParameters(queryParameters)) 647 if len(clientRequestID) > 0 { 648 preparer = autorest.DecoratePreparer(preparer, 649 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 650 } 651 if returnClientRequestID != nil { 652 preparer = autorest.DecoratePreparer(preparer, 653 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 654 } 655 if ocpDate != nil { 656 preparer = autorest.DecoratePreparer(preparer, 657 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 658 } 659 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 660} 661 662// ListSender sends the List request. The method will close the 663// http.Response Body if it receives an error. 664func (client ComputeNodeClient) ListSender(req *http.Request) (*http.Response, error) { 665 return autorest.SendWithSender(client, req, 666 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 667} 668 669// ListResponder handles the response to the List request. The method always 670// closes the http.Response Body. 671func (client ComputeNodeClient) ListResponder(resp *http.Response) (result ComputeNodeListResult, err error) { 672 err = autorest.Respond( 673 resp, 674 client.ByInspecting(), 675 azure.WithErrorUnlessStatusCode(http.StatusOK), 676 autorest.ByUnmarshallingJSON(&result), 677 autorest.ByClosing()) 678 result.Response = autorest.Response{Response: resp} 679 return 680} 681 682// listNextResults retrieves the next set of results, if any. 683func (client ComputeNodeClient) listNextResults(lastResults ComputeNodeListResult) (result ComputeNodeListResult, err error) { 684 req, err := lastResults.computeNodeListResultPreparer() 685 if err != nil { 686 return result, autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", nil, "Failure preparing next results request") 687 } 688 if req == nil { 689 return 690 } 691 resp, err := client.ListSender(req) 692 if err != nil { 693 result.Response = autorest.Response{Response: resp} 694 return result, autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", resp, "Failure sending next results request") 695 } 696 result, err = client.ListResponder(resp) 697 if err != nil { 698 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", resp, "Failure responding to next results request") 699 } 700 return 701} 702 703// ListComplete enumerates all values, automatically crossing page boundaries as required. 704func (client ComputeNodeClient) ListComplete(ctx context.Context, poolID string, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNodeListResultIterator, err error) { 705 result.page, err = client.List(ctx, poolID, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 706 return 707} 708 709// Reboot restarts the specified compute node. 710// 711// poolID is the id of the pool that contains the compute node. nodeID is the id of the compute node that you want 712// to restart. nodeRebootParameter is the parameters for the request. timeout is sets the maximum time that the 713// server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is caller 714// generated request identity, in the form of a GUID with no decoration such as curly braces e.g. 715// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return the 716// client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified, this 717// header will be automatically populated with the current system clock time. 718func (client ComputeNodeClient) Reboot(ctx context.Context, poolID string, nodeID string, nodeRebootParameter *NodeRebootParameter, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 719 req, err := client.RebootPreparer(ctx, poolID, nodeID, nodeRebootParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 720 if err != nil { 721 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", nil, "Failure preparing request") 722 return 723 } 724 725 resp, err := client.RebootSender(req) 726 if err != nil { 727 result.Response = resp 728 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", resp, "Failure sending request") 729 return 730 } 731 732 result, err = client.RebootResponder(resp) 733 if err != nil { 734 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", resp, "Failure responding to request") 735 } 736 737 return 738} 739 740// RebootPreparer prepares the Reboot request. 741func (client ComputeNodeClient) RebootPreparer(ctx context.Context, poolID string, nodeID string, nodeRebootParameter *NodeRebootParameter, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 742 pathParameters := map[string]interface{}{ 743 "nodeId": autorest.Encode("path", nodeID), 744 "poolId": autorest.Encode("path", poolID), 745 } 746 747 const APIVersion = "2015-12-01.2.2" 748 queryParameters := map[string]interface{}{ 749 "api-version": APIVersion, 750 } 751 if timeout != nil { 752 queryParameters["timeout"] = autorest.Encode("query", *timeout) 753 } else { 754 queryParameters["timeout"] = autorest.Encode("query", 30) 755 } 756 757 preparer := autorest.CreatePreparer( 758 autorest.AsJSON(), 759 autorest.AsPost(), 760 autorest.WithBaseURL(client.BaseURI), 761 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/reboot", pathParameters), 762 autorest.WithQueryParameters(queryParameters)) 763 if nodeRebootParameter != nil { 764 preparer = autorest.DecoratePreparer(preparer, 765 autorest.WithJSON(nodeRebootParameter)) 766 } 767 if len(clientRequestID) > 0 { 768 preparer = autorest.DecoratePreparer(preparer, 769 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 770 } 771 if returnClientRequestID != nil { 772 preparer = autorest.DecoratePreparer(preparer, 773 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 774 } 775 if ocpDate != nil { 776 preparer = autorest.DecoratePreparer(preparer, 777 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 778 } 779 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 780} 781 782// RebootSender sends the Reboot request. The method will close the 783// http.Response Body if it receives an error. 784func (client ComputeNodeClient) RebootSender(req *http.Request) (*http.Response, error) { 785 return autorest.SendWithSender(client, req, 786 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 787} 788 789// RebootResponder handles the response to the Reboot request. The method always 790// closes the http.Response Body. 791func (client ComputeNodeClient) RebootResponder(resp *http.Response) (result autorest.Response, err error) { 792 err = autorest.Respond( 793 resp, 794 client.ByInspecting(), 795 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 796 autorest.ByClosing()) 797 result.Response = resp 798 return 799} 800 801// Reimage reinstalls the operating system on the specified compute node. 802// 803// poolID is the id of the pool that contains the compute node. nodeID is the id of the compute node that you want 804// to restart. nodeReimageParameter is the parameters for the request. timeout is sets the maximum time that the 805// server can spend processing the request, in seconds. The default is 30 seconds. clientRequestID is caller 806// generated request identity, in the form of a GUID with no decoration such as curly braces e.g. 807// 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is specifies if the server should return the 808// client-request-id identifier in the response. ocpDate is the time the request was issued. If not specified, this 809// header will be automatically populated with the current system clock time. 810func (client ComputeNodeClient) Reimage(ctx context.Context, poolID string, nodeID string, nodeReimageParameter *NodeReimageParameter, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 811 req, err := client.ReimagePreparer(ctx, poolID, nodeID, nodeReimageParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 812 if err != nil { 813 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", nil, "Failure preparing request") 814 return 815 } 816 817 resp, err := client.ReimageSender(req) 818 if err != nil { 819 result.Response = resp 820 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", resp, "Failure sending request") 821 return 822 } 823 824 result, err = client.ReimageResponder(resp) 825 if err != nil { 826 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", resp, "Failure responding to request") 827 } 828 829 return 830} 831 832// ReimagePreparer prepares the Reimage request. 833func (client ComputeNodeClient) ReimagePreparer(ctx context.Context, poolID string, nodeID string, nodeReimageParameter *NodeReimageParameter, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 834 pathParameters := map[string]interface{}{ 835 "nodeId": autorest.Encode("path", nodeID), 836 "poolId": autorest.Encode("path", poolID), 837 } 838 839 const APIVersion = "2015-12-01.2.2" 840 queryParameters := map[string]interface{}{ 841 "api-version": APIVersion, 842 } 843 if timeout != nil { 844 queryParameters["timeout"] = autorest.Encode("query", *timeout) 845 } else { 846 queryParameters["timeout"] = autorest.Encode("query", 30) 847 } 848 849 preparer := autorest.CreatePreparer( 850 autorest.AsJSON(), 851 autorest.AsPost(), 852 autorest.WithBaseURL(client.BaseURI), 853 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/reimage", pathParameters), 854 autorest.WithQueryParameters(queryParameters)) 855 if nodeReimageParameter != nil { 856 preparer = autorest.DecoratePreparer(preparer, 857 autorest.WithJSON(nodeReimageParameter)) 858 } 859 if len(clientRequestID) > 0 { 860 preparer = autorest.DecoratePreparer(preparer, 861 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 862 } 863 if returnClientRequestID != nil { 864 preparer = autorest.DecoratePreparer(preparer, 865 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 866 } 867 if ocpDate != nil { 868 preparer = autorest.DecoratePreparer(preparer, 869 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 870 } 871 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 872} 873 874// ReimageSender sends the Reimage request. The method will close the 875// http.Response Body if it receives an error. 876func (client ComputeNodeClient) ReimageSender(req *http.Request) (*http.Response, error) { 877 return autorest.SendWithSender(client, req, 878 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 879} 880 881// ReimageResponder handles the response to the Reimage request. The method always 882// closes the http.Response Body. 883func (client ComputeNodeClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) { 884 err = autorest.Respond( 885 resp, 886 client.ByInspecting(), 887 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 888 autorest.ByClosing()) 889 result.Response = resp 890 return 891} 892 893// UpdateUser updates the password or expiration time of a user account on the specified compute node. 894// 895// poolID is the id of the pool that contains the compute node. nodeID is the id of the machine on which you want 896// to update a user account. userName is the name of the user account to update. nodeUpdateUserParameter is the 897// parameters for the request. timeout is sets the maximum time that the server can spend processing the request, 898// in seconds. The default is 30 seconds. clientRequestID is caller generated request identity, in the form of a 899// GUID with no decoration such as curly braces e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is 900// specifies if the server should return the client-request-id identifier in the response. ocpDate is the time the 901// request was issued. If not specified, this header will be automatically populated with the current system clock 902// time. 903func (client ComputeNodeClient) UpdateUser(ctx context.Context, poolID string, nodeID string, userName string, nodeUpdateUserParameter NodeUpdateUserParameter, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 904 if err := validation.Validate([]validation.Validation{ 905 {TargetValue: nodeUpdateUserParameter, 906 Constraints: []validation.Constraint{{Target: "nodeUpdateUserParameter.Password", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 907 return result, validation.NewError("batch.ComputeNodeClient", "UpdateUser", err.Error()) 908 } 909 910 req, err := client.UpdateUserPreparer(ctx, poolID, nodeID, userName, nodeUpdateUserParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 911 if err != nil { 912 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", nil, "Failure preparing request") 913 return 914 } 915 916 resp, err := client.UpdateUserSender(req) 917 if err != nil { 918 result.Response = resp 919 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", resp, "Failure sending request") 920 return 921 } 922 923 result, err = client.UpdateUserResponder(resp) 924 if err != nil { 925 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", resp, "Failure responding to request") 926 } 927 928 return 929} 930 931// UpdateUserPreparer prepares the UpdateUser request. 932func (client ComputeNodeClient) UpdateUserPreparer(ctx context.Context, poolID string, nodeID string, userName string, nodeUpdateUserParameter NodeUpdateUserParameter, timeout *int32, clientRequestID string, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 933 pathParameters := map[string]interface{}{ 934 "nodeId": autorest.Encode("path", nodeID), 935 "poolId": autorest.Encode("path", poolID), 936 "userName": autorest.Encode("path", userName), 937 } 938 939 const APIVersion = "2015-12-01.2.2" 940 queryParameters := map[string]interface{}{ 941 "api-version": APIVersion, 942 } 943 if timeout != nil { 944 queryParameters["timeout"] = autorest.Encode("query", *timeout) 945 } else { 946 queryParameters["timeout"] = autorest.Encode("query", 30) 947 } 948 949 preparer := autorest.CreatePreparer( 950 autorest.AsJSON(), 951 autorest.AsPut(), 952 autorest.WithBaseURL(client.BaseURI), 953 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/users/{userName}", pathParameters), 954 autorest.WithJSON(nodeUpdateUserParameter), 955 autorest.WithQueryParameters(queryParameters)) 956 if len(clientRequestID) > 0 { 957 preparer = autorest.DecoratePreparer(preparer, 958 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 959 } 960 if returnClientRequestID != nil { 961 preparer = autorest.DecoratePreparer(preparer, 962 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 963 } 964 if ocpDate != nil { 965 preparer = autorest.DecoratePreparer(preparer, 966 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 967 } 968 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 969} 970 971// UpdateUserSender sends the UpdateUser request. The method will close the 972// http.Response Body if it receives an error. 973func (client ComputeNodeClient) UpdateUserSender(req *http.Request) (*http.Response, error) { 974 return autorest.SendWithSender(client, req, 975 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 976} 977 978// UpdateUserResponder handles the response to the UpdateUser request. The method always 979// closes the http.Response Body. 980func (client ComputeNodeClient) UpdateUserResponder(resp *http.Response) (result autorest.Response, err error) { 981 err = autorest.Respond( 982 resp, 983 client.ByInspecting(), 984 azure.WithErrorUnlessStatusCode(http.StatusOK), 985 autorest.ByClosing()) 986 result.Response = resp 987 return 988} 989