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/Azure/go-autorest/tracing" 27 "github.com/satori/go.uuid" 28 "net/http" 29) 30 31// ComputeNodeClient is the a client for issuing REST requests to the Azure Batch service. 32type ComputeNodeClient struct { 33 BaseClient 34} 35 36// NewComputeNodeClient creates an instance of the ComputeNodeClient client. 37func NewComputeNodeClient() ComputeNodeClient { 38 return NewComputeNodeClientWithBaseURI(DefaultBaseURI) 39} 40 41// NewComputeNodeClientWithBaseURI creates an instance of the ComputeNodeClient client using a custom endpoint. Use 42// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 43func NewComputeNodeClientWithBaseURI(baseURI string) ComputeNodeClient { 44 return ComputeNodeClient{NewWithBaseURI(baseURI)} 45} 46 47// AddUser you can add a user account to a node only when it is in the idle or running state. 48// Parameters: 49// poolID - the ID of the pool that contains the compute node. 50// nodeID - the ID of the machine on which you want to create a user account. 51// userParameter - the user account to be created. 52// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 53// seconds. 54// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 55// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 56// returnClientRequestID - whether the server should return the client-request-id in the response. 57// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 58// time; set it explicitly if you are calling the REST API directly. 59func (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) { 60 if tracing.IsEnabled() { 61 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.AddUser") 62 defer func() { 63 sc := -1 64 if result.Response != nil { 65 sc = result.Response.StatusCode 66 } 67 tracing.EndSpan(ctx, sc, err) 68 }() 69 } 70 if err := validation.Validate([]validation.Validation{ 71 {TargetValue: userParameter, 72 Constraints: []validation.Constraint{{Target: "userParameter.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 73 return result, validation.NewError("batch.ComputeNodeClient", "AddUser", err.Error()) 74 } 75 76 req, err := client.AddUserPreparer(ctx, poolID, nodeID, userParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 77 if err != nil { 78 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "AddUser", nil, "Failure preparing request") 79 return 80 } 81 82 resp, err := client.AddUserSender(req) 83 if err != nil { 84 result.Response = resp 85 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "AddUser", resp, "Failure sending request") 86 return 87 } 88 89 result, err = client.AddUserResponder(resp) 90 if err != nil { 91 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "AddUser", resp, "Failure responding to request") 92 return 93 } 94 95 return 96} 97 98// AddUserPreparer prepares the AddUser request. 99func (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) { 100 pathParameters := map[string]interface{}{ 101 "nodeId": autorest.Encode("path", nodeID), 102 "poolId": autorest.Encode("path", poolID), 103 } 104 105 const APIVersion = "2018-03-01.6.1" 106 queryParameters := map[string]interface{}{ 107 "api-version": APIVersion, 108 } 109 if timeout != nil { 110 queryParameters["timeout"] = autorest.Encode("query", *timeout) 111 } else { 112 queryParameters["timeout"] = autorest.Encode("query", 30) 113 } 114 115 preparer := autorest.CreatePreparer( 116 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 117 autorest.AsPost(), 118 autorest.WithBaseURL(client.BaseURI), 119 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/users", pathParameters), 120 autorest.WithJSON(userParameter), 121 autorest.WithQueryParameters(queryParameters)) 122 if clientRequestID != nil { 123 preparer = autorest.DecoratePreparer(preparer, 124 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 125 } 126 if returnClientRequestID != nil { 127 preparer = autorest.DecoratePreparer(preparer, 128 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 129 } else { 130 preparer = autorest.DecoratePreparer(preparer, 131 autorest.WithHeader("return-client-request-id", autorest.String(false))) 132 } 133 if ocpDate != nil { 134 preparer = autorest.DecoratePreparer(preparer, 135 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 136 } 137 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 138} 139 140// AddUserSender sends the AddUser request. The method will close the 141// http.Response Body if it receives an error. 142func (client ComputeNodeClient) AddUserSender(req *http.Request) (*http.Response, error) { 143 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 144} 145 146// AddUserResponder handles the response to the AddUser request. The method always 147// closes the http.Response Body. 148func (client ComputeNodeClient) AddUserResponder(resp *http.Response) (result autorest.Response, err error) { 149 err = autorest.Respond( 150 resp, 151 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 152 autorest.ByClosing()) 153 result.Response = resp 154 return 155} 156 157// DeleteUser you can delete a user account to a node only when it is in the idle or running state. 158// Parameters: 159// poolID - the ID of the pool that contains the compute node. 160// nodeID - the ID of the machine on which you want to delete a user account. 161// userName - the name of the user account to delete. 162// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 163// seconds. 164// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 165// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 166// returnClientRequestID - whether the server should return the client-request-id in the response. 167// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 168// time; set it explicitly if you are calling the REST API directly. 169func (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) { 170 if tracing.IsEnabled() { 171 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.DeleteUser") 172 defer func() { 173 sc := -1 174 if result.Response != nil { 175 sc = result.Response.StatusCode 176 } 177 tracing.EndSpan(ctx, sc, err) 178 }() 179 } 180 req, err := client.DeleteUserPreparer(ctx, poolID, nodeID, userName, timeout, clientRequestID, returnClientRequestID, ocpDate) 181 if err != nil { 182 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DeleteUser", nil, "Failure preparing request") 183 return 184 } 185 186 resp, err := client.DeleteUserSender(req) 187 if err != nil { 188 result.Response = resp 189 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DeleteUser", resp, "Failure sending request") 190 return 191 } 192 193 result, err = client.DeleteUserResponder(resp) 194 if err != nil { 195 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DeleteUser", resp, "Failure responding to request") 196 return 197 } 198 199 return 200} 201 202// DeleteUserPreparer prepares the DeleteUser request. 203func (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) { 204 pathParameters := map[string]interface{}{ 205 "nodeId": autorest.Encode("path", nodeID), 206 "poolId": autorest.Encode("path", poolID), 207 "userName": autorest.Encode("path", userName), 208 } 209 210 const APIVersion = "2018-03-01.6.1" 211 queryParameters := map[string]interface{}{ 212 "api-version": APIVersion, 213 } 214 if timeout != nil { 215 queryParameters["timeout"] = autorest.Encode("query", *timeout) 216 } else { 217 queryParameters["timeout"] = autorest.Encode("query", 30) 218 } 219 220 preparer := autorest.CreatePreparer( 221 autorest.AsDelete(), 222 autorest.WithBaseURL(client.BaseURI), 223 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/users/{userName}", pathParameters), 224 autorest.WithQueryParameters(queryParameters)) 225 if clientRequestID != nil { 226 preparer = autorest.DecoratePreparer(preparer, 227 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 228 } 229 if returnClientRequestID != nil { 230 preparer = autorest.DecoratePreparer(preparer, 231 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 232 } else { 233 preparer = autorest.DecoratePreparer(preparer, 234 autorest.WithHeader("return-client-request-id", autorest.String(false))) 235 } 236 if ocpDate != nil { 237 preparer = autorest.DecoratePreparer(preparer, 238 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 239 } 240 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 241} 242 243// DeleteUserSender sends the DeleteUser request. The method will close the 244// http.Response Body if it receives an error. 245func (client ComputeNodeClient) DeleteUserSender(req *http.Request) (*http.Response, error) { 246 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 247} 248 249// DeleteUserResponder handles the response to the DeleteUser request. The method always 250// closes the http.Response Body. 251func (client ComputeNodeClient) DeleteUserResponder(resp *http.Response) (result autorest.Response, err error) { 252 err = autorest.Respond( 253 resp, 254 azure.WithErrorUnlessStatusCode(http.StatusOK), 255 autorest.ByClosing()) 256 result.Response = resp 257 return 258} 259 260// DisableScheduling you can disable task scheduling on a node only if its current scheduling state is enabled. 261// Parameters: 262// poolID - the ID of the pool that contains the compute node. 263// nodeID - the ID of the compute node on which you want to disable task scheduling. 264// nodeDisableSchedulingParameter - the parameters for the request. 265// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 266// seconds. 267// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 268// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 269// returnClientRequestID - whether the server should return the client-request-id in the response. 270// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 271// time; set it explicitly if you are calling the REST API directly. 272func (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) { 273 if tracing.IsEnabled() { 274 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.DisableScheduling") 275 defer func() { 276 sc := -1 277 if result.Response != nil { 278 sc = result.Response.StatusCode 279 } 280 tracing.EndSpan(ctx, sc, err) 281 }() 282 } 283 req, err := client.DisableSchedulingPreparer(ctx, poolID, nodeID, nodeDisableSchedulingParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 284 if err != nil { 285 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DisableScheduling", nil, "Failure preparing request") 286 return 287 } 288 289 resp, err := client.DisableSchedulingSender(req) 290 if err != nil { 291 result.Response = resp 292 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DisableScheduling", resp, "Failure sending request") 293 return 294 } 295 296 result, err = client.DisableSchedulingResponder(resp) 297 if err != nil { 298 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DisableScheduling", resp, "Failure responding to request") 299 return 300 } 301 302 return 303} 304 305// DisableSchedulingPreparer prepares the DisableScheduling request. 306func (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) { 307 pathParameters := map[string]interface{}{ 308 "nodeId": autorest.Encode("path", nodeID), 309 "poolId": autorest.Encode("path", poolID), 310 } 311 312 const APIVersion = "2018-03-01.6.1" 313 queryParameters := map[string]interface{}{ 314 "api-version": APIVersion, 315 } 316 if timeout != nil { 317 queryParameters["timeout"] = autorest.Encode("query", *timeout) 318 } else { 319 queryParameters["timeout"] = autorest.Encode("query", 30) 320 } 321 322 preparer := autorest.CreatePreparer( 323 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 324 autorest.AsPost(), 325 autorest.WithBaseURL(client.BaseURI), 326 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/disablescheduling", pathParameters), 327 autorest.WithQueryParameters(queryParameters)) 328 if nodeDisableSchedulingParameter != nil { 329 preparer = autorest.DecoratePreparer(preparer, 330 autorest.WithJSON(nodeDisableSchedulingParameter)) 331 } 332 if clientRequestID != nil { 333 preparer = autorest.DecoratePreparer(preparer, 334 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 335 } 336 if returnClientRequestID != nil { 337 preparer = autorest.DecoratePreparer(preparer, 338 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 339 } else { 340 preparer = autorest.DecoratePreparer(preparer, 341 autorest.WithHeader("return-client-request-id", autorest.String(false))) 342 } 343 if ocpDate != nil { 344 preparer = autorest.DecoratePreparer(preparer, 345 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 346 } 347 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 348} 349 350// DisableSchedulingSender sends the DisableScheduling request. The method will close the 351// http.Response Body if it receives an error. 352func (client ComputeNodeClient) DisableSchedulingSender(req *http.Request) (*http.Response, error) { 353 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 354} 355 356// DisableSchedulingResponder handles the response to the DisableScheduling request. The method always 357// closes the http.Response Body. 358func (client ComputeNodeClient) DisableSchedulingResponder(resp *http.Response) (result autorest.Response, err error) { 359 err = autorest.Respond( 360 resp, 361 azure.WithErrorUnlessStatusCode(http.StatusOK), 362 autorest.ByClosing()) 363 result.Response = resp 364 return 365} 366 367// EnableScheduling you can enable task scheduling on a node only if its current scheduling state is disabled 368// Parameters: 369// poolID - the ID of the pool that contains the compute node. 370// nodeID - the ID of the compute node on which you want to enable task scheduling. 371// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 372// seconds. 373// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 374// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 375// returnClientRequestID - whether the server should return the client-request-id in the response. 376// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 377// time; set it explicitly if you are calling the REST API directly. 378func (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) { 379 if tracing.IsEnabled() { 380 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.EnableScheduling") 381 defer func() { 382 sc := -1 383 if result.Response != nil { 384 sc = result.Response.StatusCode 385 } 386 tracing.EndSpan(ctx, sc, err) 387 }() 388 } 389 req, err := client.EnableSchedulingPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate) 390 if err != nil { 391 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "EnableScheduling", nil, "Failure preparing request") 392 return 393 } 394 395 resp, err := client.EnableSchedulingSender(req) 396 if err != nil { 397 result.Response = resp 398 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "EnableScheduling", resp, "Failure sending request") 399 return 400 } 401 402 result, err = client.EnableSchedulingResponder(resp) 403 if err != nil { 404 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "EnableScheduling", resp, "Failure responding to request") 405 return 406 } 407 408 return 409} 410 411// EnableSchedulingPreparer prepares the EnableScheduling request. 412func (client ComputeNodeClient) EnableSchedulingPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 413 pathParameters := map[string]interface{}{ 414 "nodeId": autorest.Encode("path", nodeID), 415 "poolId": autorest.Encode("path", poolID), 416 } 417 418 const APIVersion = "2018-03-01.6.1" 419 queryParameters := map[string]interface{}{ 420 "api-version": APIVersion, 421 } 422 if timeout != nil { 423 queryParameters["timeout"] = autorest.Encode("query", *timeout) 424 } else { 425 queryParameters["timeout"] = autorest.Encode("query", 30) 426 } 427 428 preparer := autorest.CreatePreparer( 429 autorest.AsPost(), 430 autorest.WithBaseURL(client.BaseURI), 431 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/enablescheduling", pathParameters), 432 autorest.WithQueryParameters(queryParameters)) 433 if clientRequestID != nil { 434 preparer = autorest.DecoratePreparer(preparer, 435 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 436 } 437 if returnClientRequestID != nil { 438 preparer = autorest.DecoratePreparer(preparer, 439 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 440 } else { 441 preparer = autorest.DecoratePreparer(preparer, 442 autorest.WithHeader("return-client-request-id", autorest.String(false))) 443 } 444 if ocpDate != nil { 445 preparer = autorest.DecoratePreparer(preparer, 446 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 447 } 448 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 449} 450 451// EnableSchedulingSender sends the EnableScheduling request. The method will close the 452// http.Response Body if it receives an error. 453func (client ComputeNodeClient) EnableSchedulingSender(req *http.Request) (*http.Response, error) { 454 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 455} 456 457// EnableSchedulingResponder handles the response to the EnableScheduling request. The method always 458// closes the http.Response Body. 459func (client ComputeNodeClient) EnableSchedulingResponder(resp *http.Response) (result autorest.Response, err error) { 460 err = autorest.Respond( 461 resp, 462 azure.WithErrorUnlessStatusCode(http.StatusOK), 463 autorest.ByClosing()) 464 result.Response = resp 465 return 466} 467 468// Get sends the get request. 469// Parameters: 470// poolID - the ID of the pool that contains the compute node. 471// nodeID - the ID of the compute node that you want to get information about. 472// selectParameter - an OData $select clause. 473// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 474// seconds. 475// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 476// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 477// returnClientRequestID - whether the server should return the client-request-id in the response. 478// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 479// time; set it explicitly if you are calling the REST API directly. 480func (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) { 481 if tracing.IsEnabled() { 482 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.Get") 483 defer func() { 484 sc := -1 485 if result.Response.Response != nil { 486 sc = result.Response.Response.StatusCode 487 } 488 tracing.EndSpan(ctx, sc, err) 489 }() 490 } 491 req, err := client.GetPreparer(ctx, poolID, nodeID, selectParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 492 if err != nil { 493 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Get", nil, "Failure preparing request") 494 return 495 } 496 497 resp, err := client.GetSender(req) 498 if err != nil { 499 result.Response = autorest.Response{Response: resp} 500 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Get", resp, "Failure sending request") 501 return 502 } 503 504 result, err = client.GetResponder(resp) 505 if err != nil { 506 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Get", resp, "Failure responding to request") 507 return 508 } 509 510 return 511} 512 513// GetPreparer prepares the Get request. 514func (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) { 515 pathParameters := map[string]interface{}{ 516 "nodeId": autorest.Encode("path", nodeID), 517 "poolId": autorest.Encode("path", poolID), 518 } 519 520 const APIVersion = "2018-03-01.6.1" 521 queryParameters := map[string]interface{}{ 522 "api-version": APIVersion, 523 } 524 if len(selectParameter) > 0 { 525 queryParameters["$select"] = autorest.Encode("query", selectParameter) 526 } 527 if timeout != nil { 528 queryParameters["timeout"] = autorest.Encode("query", *timeout) 529 } else { 530 queryParameters["timeout"] = autorest.Encode("query", 30) 531 } 532 533 preparer := autorest.CreatePreparer( 534 autorest.AsGet(), 535 autorest.WithBaseURL(client.BaseURI), 536 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}", pathParameters), 537 autorest.WithQueryParameters(queryParameters)) 538 if clientRequestID != nil { 539 preparer = autorest.DecoratePreparer(preparer, 540 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 541 } 542 if returnClientRequestID != nil { 543 preparer = autorest.DecoratePreparer(preparer, 544 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 545 } else { 546 preparer = autorest.DecoratePreparer(preparer, 547 autorest.WithHeader("return-client-request-id", autorest.String(false))) 548 } 549 if ocpDate != nil { 550 preparer = autorest.DecoratePreparer(preparer, 551 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 552 } 553 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 554} 555 556// GetSender sends the Get request. The method will close the 557// http.Response Body if it receives an error. 558func (client ComputeNodeClient) GetSender(req *http.Request) (*http.Response, error) { 559 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 560} 561 562// GetResponder handles the response to the Get request. The method always 563// closes the http.Response Body. 564func (client ComputeNodeClient) GetResponder(resp *http.Response) (result ComputeNode, err error) { 565 err = autorest.Respond( 566 resp, 567 azure.WithErrorUnlessStatusCode(http.StatusOK), 568 autorest.ByUnmarshallingJSON(&result), 569 autorest.ByClosing()) 570 result.Response = autorest.Response{Response: resp} 571 return 572} 573 574// GetRemoteDesktop before you can access a node by using the RDP file, you must create a user account on the node. 575// This API can only be invoked on pools created with a cloud service configuration. For pools created with a virtual 576// machine configuration, see the GetRemoteLoginSettings API. 577// Parameters: 578// poolID - the ID of the pool that contains the compute node. 579// nodeID - the ID of the compute node for which you want to get the Remote Desktop Protocol file. 580// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 581// seconds. 582// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 583// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 584// returnClientRequestID - whether the server should return the client-request-id in the response. 585// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 586// time; set it explicitly if you are calling the REST API directly. 587func (client ComputeNodeClient) GetRemoteDesktop(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ReadCloser, err error) { 588 if tracing.IsEnabled() { 589 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.GetRemoteDesktop") 590 defer func() { 591 sc := -1 592 if result.Response.Response != nil { 593 sc = result.Response.Response.StatusCode 594 } 595 tracing.EndSpan(ctx, sc, err) 596 }() 597 } 598 req, err := client.GetRemoteDesktopPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate) 599 if err != nil { 600 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", nil, "Failure preparing request") 601 return 602 } 603 604 resp, err := client.GetRemoteDesktopSender(req) 605 if err != nil { 606 result.Response = autorest.Response{Response: resp} 607 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", resp, "Failure sending request") 608 return 609 } 610 611 result, err = client.GetRemoteDesktopResponder(resp) 612 if err != nil { 613 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", resp, "Failure responding to request") 614 return 615 } 616 617 return 618} 619 620// GetRemoteDesktopPreparer prepares the GetRemoteDesktop request. 621func (client ComputeNodeClient) GetRemoteDesktopPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 622 pathParameters := map[string]interface{}{ 623 "nodeId": autorest.Encode("path", nodeID), 624 "poolId": autorest.Encode("path", poolID), 625 } 626 627 const APIVersion = "2018-03-01.6.1" 628 queryParameters := map[string]interface{}{ 629 "api-version": APIVersion, 630 } 631 if timeout != nil { 632 queryParameters["timeout"] = autorest.Encode("query", *timeout) 633 } else { 634 queryParameters["timeout"] = autorest.Encode("query", 30) 635 } 636 637 preparer := autorest.CreatePreparer( 638 autorest.AsGet(), 639 autorest.WithBaseURL(client.BaseURI), 640 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/rdp", pathParameters), 641 autorest.WithQueryParameters(queryParameters)) 642 if clientRequestID != nil { 643 preparer = autorest.DecoratePreparer(preparer, 644 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 645 } 646 if returnClientRequestID != nil { 647 preparer = autorest.DecoratePreparer(preparer, 648 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 649 } else { 650 preparer = autorest.DecoratePreparer(preparer, 651 autorest.WithHeader("return-client-request-id", autorest.String(false))) 652 } 653 if ocpDate != nil { 654 preparer = autorest.DecoratePreparer(preparer, 655 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 656 } 657 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 658} 659 660// GetRemoteDesktopSender sends the GetRemoteDesktop request. The method will close the 661// http.Response Body if it receives an error. 662func (client ComputeNodeClient) GetRemoteDesktopSender(req *http.Request) (*http.Response, error) { 663 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 664} 665 666// GetRemoteDesktopResponder handles the response to the GetRemoteDesktop request. The method always 667// closes the http.Response Body. 668func (client ComputeNodeClient) GetRemoteDesktopResponder(resp *http.Response) (result ReadCloser, err error) { 669 result.Value = &resp.Body 670 err = autorest.Respond( 671 resp, 672 azure.WithErrorUnlessStatusCode(http.StatusOK)) 673 result.Response = autorest.Response{Response: resp} 674 return 675} 676 677// GetRemoteLoginSettings before you can remotely login to a node using the remote login settings, you must create a 678// user account on the node. This API can be invoked only on pools created with the virtual machine configuration 679// property. For pools created with a cloud service configuration, see the GetRemoteDesktop API. 680// Parameters: 681// poolID - the ID of the pool that contains the compute node. 682// nodeID - the ID of the compute node for which to obtain the remote login settings. 683// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 684// seconds. 685// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 686// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 687// returnClientRequestID - whether the server should return the client-request-id in the response. 688// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 689// time; set it explicitly if you are calling the REST API directly. 690func (client ComputeNodeClient) GetRemoteLoginSettings(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNodeGetRemoteLoginSettingsResult, err error) { 691 if tracing.IsEnabled() { 692 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.GetRemoteLoginSettings") 693 defer func() { 694 sc := -1 695 if result.Response.Response != nil { 696 sc = result.Response.Response.StatusCode 697 } 698 tracing.EndSpan(ctx, sc, err) 699 }() 700 } 701 req, err := client.GetRemoteLoginSettingsPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate) 702 if err != nil { 703 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteLoginSettings", nil, "Failure preparing request") 704 return 705 } 706 707 resp, err := client.GetRemoteLoginSettingsSender(req) 708 if err != nil { 709 result.Response = autorest.Response{Response: resp} 710 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteLoginSettings", resp, "Failure sending request") 711 return 712 } 713 714 result, err = client.GetRemoteLoginSettingsResponder(resp) 715 if err != nil { 716 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteLoginSettings", resp, "Failure responding to request") 717 return 718 } 719 720 return 721} 722 723// GetRemoteLoginSettingsPreparer prepares the GetRemoteLoginSettings request. 724func (client ComputeNodeClient) GetRemoteLoginSettingsPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 725 pathParameters := map[string]interface{}{ 726 "nodeId": autorest.Encode("path", nodeID), 727 "poolId": autorest.Encode("path", poolID), 728 } 729 730 const APIVersion = "2018-03-01.6.1" 731 queryParameters := map[string]interface{}{ 732 "api-version": APIVersion, 733 } 734 if timeout != nil { 735 queryParameters["timeout"] = autorest.Encode("query", *timeout) 736 } else { 737 queryParameters["timeout"] = autorest.Encode("query", 30) 738 } 739 740 preparer := autorest.CreatePreparer( 741 autorest.AsGet(), 742 autorest.WithBaseURL(client.BaseURI), 743 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/remoteloginsettings", pathParameters), 744 autorest.WithQueryParameters(queryParameters)) 745 if clientRequestID != nil { 746 preparer = autorest.DecoratePreparer(preparer, 747 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 748 } 749 if returnClientRequestID != nil { 750 preparer = autorest.DecoratePreparer(preparer, 751 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 752 } else { 753 preparer = autorest.DecoratePreparer(preparer, 754 autorest.WithHeader("return-client-request-id", autorest.String(false))) 755 } 756 if ocpDate != nil { 757 preparer = autorest.DecoratePreparer(preparer, 758 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 759 } 760 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 761} 762 763// GetRemoteLoginSettingsSender sends the GetRemoteLoginSettings request. The method will close the 764// http.Response Body if it receives an error. 765func (client ComputeNodeClient) GetRemoteLoginSettingsSender(req *http.Request) (*http.Response, error) { 766 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 767} 768 769// GetRemoteLoginSettingsResponder handles the response to the GetRemoteLoginSettings request. The method always 770// closes the http.Response Body. 771func (client ComputeNodeClient) GetRemoteLoginSettingsResponder(resp *http.Response) (result ComputeNodeGetRemoteLoginSettingsResult, err error) { 772 err = autorest.Respond( 773 resp, 774 azure.WithErrorUnlessStatusCode(http.StatusOK), 775 autorest.ByUnmarshallingJSON(&result), 776 autorest.ByClosing()) 777 result.Response = autorest.Response{Response: resp} 778 return 779} 780 781// List sends the list request. 782// Parameters: 783// poolID - the ID of the pool from which you want to list nodes. 784// filter - an OData $filter clause. For more information on constructing this filter, see 785// https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-nodes-in-a-pool. 786// selectParameter - an OData $select clause. 787// maxResults - the maximum number of items to return in the response. A maximum of 1000 nodes can be returned. 788// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 789// seconds. 790// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 791// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 792// returnClientRequestID - whether the server should return the client-request-id in the response. 793// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 794// time; set it explicitly if you are calling the REST API directly. 795func (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) { 796 if tracing.IsEnabled() { 797 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.List") 798 defer func() { 799 sc := -1 800 if result.cnlr.Response.Response != nil { 801 sc = result.cnlr.Response.Response.StatusCode 802 } 803 tracing.EndSpan(ctx, sc, err) 804 }() 805 } 806 if err := validation.Validate([]validation.Validation{ 807 {TargetValue: maxResults, 808 Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false, 809 Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 810 {Target: "maxResults", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 811 }}}}}); err != nil { 812 return result, validation.NewError("batch.ComputeNodeClient", "List", err.Error()) 813 } 814 815 result.fn = client.listNextResults 816 req, err := client.ListPreparer(ctx, poolID, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 817 if err != nil { 818 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", nil, "Failure preparing request") 819 return 820 } 821 822 resp, err := client.ListSender(req) 823 if err != nil { 824 result.cnlr.Response = autorest.Response{Response: resp} 825 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", resp, "Failure sending request") 826 return 827 } 828 829 result.cnlr, err = client.ListResponder(resp) 830 if err != nil { 831 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", resp, "Failure responding to request") 832 return 833 } 834 if result.cnlr.hasNextLink() && result.cnlr.IsEmpty() { 835 err = result.NextWithContext(ctx) 836 return 837 } 838 839 return 840} 841 842// ListPreparer prepares the List request. 843func (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) { 844 pathParameters := map[string]interface{}{ 845 "poolId": autorest.Encode("path", poolID), 846 } 847 848 const APIVersion = "2018-03-01.6.1" 849 queryParameters := map[string]interface{}{ 850 "api-version": APIVersion, 851 } 852 if len(filter) > 0 { 853 queryParameters["$filter"] = autorest.Encode("query", filter) 854 } 855 if len(selectParameter) > 0 { 856 queryParameters["$select"] = autorest.Encode("query", selectParameter) 857 } 858 if maxResults != nil { 859 queryParameters["maxresults"] = autorest.Encode("query", *maxResults) 860 } else { 861 queryParameters["maxresults"] = autorest.Encode("query", 1000) 862 } 863 if timeout != nil { 864 queryParameters["timeout"] = autorest.Encode("query", *timeout) 865 } else { 866 queryParameters["timeout"] = autorest.Encode("query", 30) 867 } 868 869 preparer := autorest.CreatePreparer( 870 autorest.AsGet(), 871 autorest.WithBaseURL(client.BaseURI), 872 autorest.WithPathParameters("/pools/{poolId}/nodes", pathParameters), 873 autorest.WithQueryParameters(queryParameters)) 874 if clientRequestID != nil { 875 preparer = autorest.DecoratePreparer(preparer, 876 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 877 } 878 if returnClientRequestID != nil { 879 preparer = autorest.DecoratePreparer(preparer, 880 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 881 } else { 882 preparer = autorest.DecoratePreparer(preparer, 883 autorest.WithHeader("return-client-request-id", autorest.String(false))) 884 } 885 if ocpDate != nil { 886 preparer = autorest.DecoratePreparer(preparer, 887 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 888 } 889 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 890} 891 892// ListSender sends the List request. The method will close the 893// http.Response Body if it receives an error. 894func (client ComputeNodeClient) ListSender(req *http.Request) (*http.Response, error) { 895 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 896} 897 898// ListResponder handles the response to the List request. The method always 899// closes the http.Response Body. 900func (client ComputeNodeClient) ListResponder(resp *http.Response) (result ComputeNodeListResult, err error) { 901 err = autorest.Respond( 902 resp, 903 azure.WithErrorUnlessStatusCode(http.StatusOK), 904 autorest.ByUnmarshallingJSON(&result), 905 autorest.ByClosing()) 906 result.Response = autorest.Response{Response: resp} 907 return 908} 909 910// listNextResults retrieves the next set of results, if any. 911func (client ComputeNodeClient) listNextResults(ctx context.Context, lastResults ComputeNodeListResult) (result ComputeNodeListResult, err error) { 912 req, err := lastResults.computeNodeListResultPreparer(ctx) 913 if err != nil { 914 return result, autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", nil, "Failure preparing next results request") 915 } 916 if req == nil { 917 return 918 } 919 resp, err := client.ListSender(req) 920 if err != nil { 921 result.Response = autorest.Response{Response: resp} 922 return result, autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", resp, "Failure sending next results request") 923 } 924 result, err = client.ListResponder(resp) 925 if err != nil { 926 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", resp, "Failure responding to next results request") 927 } 928 return 929} 930 931// ListComplete enumerates all values, automatically crossing page boundaries as required. 932func (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) { 933 if tracing.IsEnabled() { 934 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.List") 935 defer func() { 936 sc := -1 937 if result.Response().Response.Response != nil { 938 sc = result.page.Response().Response.Response.StatusCode 939 } 940 tracing.EndSpan(ctx, sc, err) 941 }() 942 } 943 result.page, err = client.List(ctx, poolID, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 944 return 945} 946 947// Reboot you can restart a node only if it is in an idle or running state. 948// Parameters: 949// poolID - the ID of the pool that contains the compute node. 950// nodeID - the ID of the compute node that you want to restart. 951// nodeRebootParameter - the parameters for the request. 952// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 953// seconds. 954// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 955// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 956// returnClientRequestID - whether the server should return the client-request-id in the response. 957// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 958// time; set it explicitly if you are calling the REST API directly. 959func (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) { 960 if tracing.IsEnabled() { 961 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.Reboot") 962 defer func() { 963 sc := -1 964 if result.Response != nil { 965 sc = result.Response.StatusCode 966 } 967 tracing.EndSpan(ctx, sc, err) 968 }() 969 } 970 req, err := client.RebootPreparer(ctx, poolID, nodeID, nodeRebootParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 971 if err != nil { 972 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", nil, "Failure preparing request") 973 return 974 } 975 976 resp, err := client.RebootSender(req) 977 if err != nil { 978 result.Response = resp 979 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", resp, "Failure sending request") 980 return 981 } 982 983 result, err = client.RebootResponder(resp) 984 if err != nil { 985 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", resp, "Failure responding to request") 986 return 987 } 988 989 return 990} 991 992// RebootPreparer prepares the Reboot request. 993func (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) { 994 pathParameters := map[string]interface{}{ 995 "nodeId": autorest.Encode("path", nodeID), 996 "poolId": autorest.Encode("path", poolID), 997 } 998 999 const APIVersion = "2018-03-01.6.1" 1000 queryParameters := map[string]interface{}{ 1001 "api-version": APIVersion, 1002 } 1003 if timeout != nil { 1004 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1005 } else { 1006 queryParameters["timeout"] = autorest.Encode("query", 30) 1007 } 1008 1009 preparer := autorest.CreatePreparer( 1010 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 1011 autorest.AsPost(), 1012 autorest.WithBaseURL(client.BaseURI), 1013 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/reboot", pathParameters), 1014 autorest.WithQueryParameters(queryParameters)) 1015 if nodeRebootParameter != nil { 1016 preparer = autorest.DecoratePreparer(preparer, 1017 autorest.WithJSON(nodeRebootParameter)) 1018 } 1019 if clientRequestID != nil { 1020 preparer = autorest.DecoratePreparer(preparer, 1021 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1022 } 1023 if returnClientRequestID != nil { 1024 preparer = autorest.DecoratePreparer(preparer, 1025 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1026 } else { 1027 preparer = autorest.DecoratePreparer(preparer, 1028 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1029 } 1030 if ocpDate != nil { 1031 preparer = autorest.DecoratePreparer(preparer, 1032 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1033 } 1034 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1035} 1036 1037// RebootSender sends the Reboot request. The method will close the 1038// http.Response Body if it receives an error. 1039func (client ComputeNodeClient) RebootSender(req *http.Request) (*http.Response, error) { 1040 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1041} 1042 1043// RebootResponder handles the response to the Reboot request. The method always 1044// closes the http.Response Body. 1045func (client ComputeNodeClient) RebootResponder(resp *http.Response) (result autorest.Response, err error) { 1046 err = autorest.Respond( 1047 resp, 1048 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1049 autorest.ByClosing()) 1050 result.Response = resp 1051 return 1052} 1053 1054// Reimage you can reinstall the operating system on a node only if it is in an idle or running state. This API can be 1055// invoked only on pools created with the cloud service configuration property. 1056// Parameters: 1057// poolID - the ID of the pool that contains the compute node. 1058// nodeID - the ID of the compute node that you want to restart. 1059// nodeReimageParameter - the parameters for the request. 1060// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 1061// seconds. 1062// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 1063// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 1064// returnClientRequestID - whether the server should return the client-request-id in the response. 1065// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 1066// time; set it explicitly if you are calling the REST API directly. 1067func (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) { 1068 if tracing.IsEnabled() { 1069 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.Reimage") 1070 defer func() { 1071 sc := -1 1072 if result.Response != nil { 1073 sc = result.Response.StatusCode 1074 } 1075 tracing.EndSpan(ctx, sc, err) 1076 }() 1077 } 1078 req, err := client.ReimagePreparer(ctx, poolID, nodeID, nodeReimageParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 1079 if err != nil { 1080 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", nil, "Failure preparing request") 1081 return 1082 } 1083 1084 resp, err := client.ReimageSender(req) 1085 if err != nil { 1086 result.Response = resp 1087 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", resp, "Failure sending request") 1088 return 1089 } 1090 1091 result, err = client.ReimageResponder(resp) 1092 if err != nil { 1093 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", resp, "Failure responding to request") 1094 return 1095 } 1096 1097 return 1098} 1099 1100// ReimagePreparer prepares the Reimage request. 1101func (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) { 1102 pathParameters := map[string]interface{}{ 1103 "nodeId": autorest.Encode("path", nodeID), 1104 "poolId": autorest.Encode("path", poolID), 1105 } 1106 1107 const APIVersion = "2018-03-01.6.1" 1108 queryParameters := map[string]interface{}{ 1109 "api-version": APIVersion, 1110 } 1111 if timeout != nil { 1112 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1113 } else { 1114 queryParameters["timeout"] = autorest.Encode("query", 30) 1115 } 1116 1117 preparer := autorest.CreatePreparer( 1118 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 1119 autorest.AsPost(), 1120 autorest.WithBaseURL(client.BaseURI), 1121 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/reimage", pathParameters), 1122 autorest.WithQueryParameters(queryParameters)) 1123 if nodeReimageParameter != nil { 1124 preparer = autorest.DecoratePreparer(preparer, 1125 autorest.WithJSON(nodeReimageParameter)) 1126 } 1127 if clientRequestID != nil { 1128 preparer = autorest.DecoratePreparer(preparer, 1129 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1130 } 1131 if returnClientRequestID != nil { 1132 preparer = autorest.DecoratePreparer(preparer, 1133 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1134 } else { 1135 preparer = autorest.DecoratePreparer(preparer, 1136 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1137 } 1138 if ocpDate != nil { 1139 preparer = autorest.DecoratePreparer(preparer, 1140 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1141 } 1142 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1143} 1144 1145// ReimageSender sends the Reimage request. The method will close the 1146// http.Response Body if it receives an error. 1147func (client ComputeNodeClient) ReimageSender(req *http.Request) (*http.Response, error) { 1148 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1149} 1150 1151// ReimageResponder handles the response to the Reimage request. The method always 1152// closes the http.Response Body. 1153func (client ComputeNodeClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) { 1154 err = autorest.Respond( 1155 resp, 1156 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1157 autorest.ByClosing()) 1158 result.Response = resp 1159 return 1160} 1161 1162// UpdateUser this operation replaces of all the updatable properties of the account. For example, if the expiryTime 1163// element is not specified, the current value is replaced with the default value, not left unmodified. You can update 1164// a user account on a node only when it is in the idle or running state. 1165// Parameters: 1166// poolID - the ID of the pool that contains the compute node. 1167// nodeID - the ID of the machine on which you want to update a user account. 1168// userName - the name of the user account to update. 1169// nodeUpdateUserParameter - the parameters for the request. 1170// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 1171// seconds. 1172// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 1173// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 1174// returnClientRequestID - whether the server should return the client-request-id in the response. 1175// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 1176// time; set it explicitly if you are calling the REST API directly. 1177func (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) { 1178 if tracing.IsEnabled() { 1179 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.UpdateUser") 1180 defer func() { 1181 sc := -1 1182 if result.Response != nil { 1183 sc = result.Response.StatusCode 1184 } 1185 tracing.EndSpan(ctx, sc, err) 1186 }() 1187 } 1188 req, err := client.UpdateUserPreparer(ctx, poolID, nodeID, userName, nodeUpdateUserParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 1189 if err != nil { 1190 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", nil, "Failure preparing request") 1191 return 1192 } 1193 1194 resp, err := client.UpdateUserSender(req) 1195 if err != nil { 1196 result.Response = resp 1197 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", resp, "Failure sending request") 1198 return 1199 } 1200 1201 result, err = client.UpdateUserResponder(resp) 1202 if err != nil { 1203 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", resp, "Failure responding to request") 1204 return 1205 } 1206 1207 return 1208} 1209 1210// UpdateUserPreparer prepares the UpdateUser request. 1211func (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) { 1212 pathParameters := map[string]interface{}{ 1213 "nodeId": autorest.Encode("path", nodeID), 1214 "poolId": autorest.Encode("path", poolID), 1215 "userName": autorest.Encode("path", userName), 1216 } 1217 1218 const APIVersion = "2018-03-01.6.1" 1219 queryParameters := map[string]interface{}{ 1220 "api-version": APIVersion, 1221 } 1222 if timeout != nil { 1223 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1224 } else { 1225 queryParameters["timeout"] = autorest.Encode("query", 30) 1226 } 1227 1228 preparer := autorest.CreatePreparer( 1229 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 1230 autorest.AsPut(), 1231 autorest.WithBaseURL(client.BaseURI), 1232 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/users/{userName}", pathParameters), 1233 autorest.WithJSON(nodeUpdateUserParameter), 1234 autorest.WithQueryParameters(queryParameters)) 1235 if clientRequestID != nil { 1236 preparer = autorest.DecoratePreparer(preparer, 1237 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1238 } 1239 if returnClientRequestID != nil { 1240 preparer = autorest.DecoratePreparer(preparer, 1241 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1242 } else { 1243 preparer = autorest.DecoratePreparer(preparer, 1244 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1245 } 1246 if ocpDate != nil { 1247 preparer = autorest.DecoratePreparer(preparer, 1248 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1249 } 1250 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1251} 1252 1253// UpdateUserSender sends the UpdateUser request. The method will close the 1254// http.Response Body if it receives an error. 1255func (client ComputeNodeClient) UpdateUserSender(req *http.Request) (*http.Response, error) { 1256 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1257} 1258 1259// UpdateUserResponder handles the response to the UpdateUser request. The method always 1260// closes the http.Response Body. 1261func (client ComputeNodeClient) UpdateUserResponder(resp *http.Response) (result autorest.Response, err error) { 1262 err = autorest.Respond( 1263 resp, 1264 azure.WithErrorUnlessStatusCode(http.StatusOK), 1265 autorest.ByClosing()) 1266 result.Response = resp 1267 return 1268} 1269 1270// UploadBatchServiceLogs this is for gathering Azure Batch service log files in an automated fashion from nodes if you 1271// are experiencing an error and wish to escalate to Azure support. The Azure Batch service log files should be shared 1272// with Azure support to aid in debugging issues with the Batch service. 1273// Parameters: 1274// poolID - the ID of the pool that contains the compute node. 1275// nodeID - the ID of the compute node from which you want to upload the Azure Batch service log files. 1276// uploadBatchServiceLogsConfiguration - the Azure Batch service log files upload configuration. 1277// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 1278// seconds. 1279// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 1280// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 1281// returnClientRequestID - whether the server should return the client-request-id in the response. 1282// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 1283// time; set it explicitly if you are calling the REST API directly. 1284func (client ComputeNodeClient) UploadBatchServiceLogs(ctx context.Context, poolID string, nodeID string, uploadBatchServiceLogsConfiguration UploadBatchServiceLogsConfiguration, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result UploadBatchServiceLogsResult, err error) { 1285 if tracing.IsEnabled() { 1286 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.UploadBatchServiceLogs") 1287 defer func() { 1288 sc := -1 1289 if result.Response.Response != nil { 1290 sc = result.Response.Response.StatusCode 1291 } 1292 tracing.EndSpan(ctx, sc, err) 1293 }() 1294 } 1295 if err := validation.Validate([]validation.Validation{ 1296 {TargetValue: uploadBatchServiceLogsConfiguration, 1297 Constraints: []validation.Constraint{{Target: "uploadBatchServiceLogsConfiguration.ContainerURL", Name: validation.Null, Rule: true, Chain: nil}, 1298 {Target: "uploadBatchServiceLogsConfiguration.StartTime", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 1299 return result, validation.NewError("batch.ComputeNodeClient", "UploadBatchServiceLogs", err.Error()) 1300 } 1301 1302 req, err := client.UploadBatchServiceLogsPreparer(ctx, poolID, nodeID, uploadBatchServiceLogsConfiguration, timeout, clientRequestID, returnClientRequestID, ocpDate) 1303 if err != nil { 1304 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UploadBatchServiceLogs", nil, "Failure preparing request") 1305 return 1306 } 1307 1308 resp, err := client.UploadBatchServiceLogsSender(req) 1309 if err != nil { 1310 result.Response = autorest.Response{Response: resp} 1311 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UploadBatchServiceLogs", resp, "Failure sending request") 1312 return 1313 } 1314 1315 result, err = client.UploadBatchServiceLogsResponder(resp) 1316 if err != nil { 1317 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UploadBatchServiceLogs", resp, "Failure responding to request") 1318 return 1319 } 1320 1321 return 1322} 1323 1324// UploadBatchServiceLogsPreparer prepares the UploadBatchServiceLogs request. 1325func (client ComputeNodeClient) UploadBatchServiceLogsPreparer(ctx context.Context, poolID string, nodeID string, uploadBatchServiceLogsConfiguration UploadBatchServiceLogsConfiguration, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 1326 pathParameters := map[string]interface{}{ 1327 "nodeId": autorest.Encode("path", nodeID), 1328 "poolId": autorest.Encode("path", poolID), 1329 } 1330 1331 const APIVersion = "2018-03-01.6.1" 1332 queryParameters := map[string]interface{}{ 1333 "api-version": APIVersion, 1334 } 1335 if timeout != nil { 1336 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1337 } else { 1338 queryParameters["timeout"] = autorest.Encode("query", 30) 1339 } 1340 1341 preparer := autorest.CreatePreparer( 1342 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 1343 autorest.AsPost(), 1344 autorest.WithBaseURL(client.BaseURI), 1345 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/uploadbatchservicelogs", pathParameters), 1346 autorest.WithJSON(uploadBatchServiceLogsConfiguration), 1347 autorest.WithQueryParameters(queryParameters)) 1348 if clientRequestID != nil { 1349 preparer = autorest.DecoratePreparer(preparer, 1350 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1351 } 1352 if returnClientRequestID != nil { 1353 preparer = autorest.DecoratePreparer(preparer, 1354 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1355 } else { 1356 preparer = autorest.DecoratePreparer(preparer, 1357 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1358 } 1359 if ocpDate != nil { 1360 preparer = autorest.DecoratePreparer(preparer, 1361 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1362 } 1363 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1364} 1365 1366// UploadBatchServiceLogsSender sends the UploadBatchServiceLogs request. The method will close the 1367// http.Response Body if it receives an error. 1368func (client ComputeNodeClient) UploadBatchServiceLogsSender(req *http.Request) (*http.Response, error) { 1369 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1370} 1371 1372// UploadBatchServiceLogsResponder handles the response to the UploadBatchServiceLogs request. The method always 1373// closes the http.Response Body. 1374func (client ComputeNodeClient) UploadBatchServiceLogsResponder(resp *http.Response) (result UploadBatchServiceLogsResult, err error) { 1375 err = autorest.Respond( 1376 resp, 1377 azure.WithErrorUnlessStatusCode(http.StatusOK), 1378 autorest.ByUnmarshallingJSON(&result), 1379 autorest.ByClosing()) 1380 result.Response = autorest.Response{Response: resp} 1381 return 1382} 1383