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