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 = "2017-05-01.5.0" 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 = "2017-05-01.5.0" 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 sends the disable scheduling request. 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 = "2017-05-01.5.0" 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 sends the enable scheduling request. 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 = "2017-05-01.5.0" 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 = "2017-05-01.5.0" 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 the cloud service configuration property. 565// Parameters: 566// poolID - the ID of the pool that contains the compute node. 567// nodeID - the ID of the compute node for which you want to get the Remote Desktop Protocol file. 568// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 569// seconds. 570// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 571// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 572// returnClientRequestID - whether the server should return the client-request-id in the response. 573// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 574// time; set it explicitly if you are calling the REST API directly. 575func (client ComputeNodeClient) GetRemoteDesktop(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ReadCloser, err error) { 576 if tracing.IsEnabled() { 577 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.GetRemoteDesktop") 578 defer func() { 579 sc := -1 580 if result.Response.Response != nil { 581 sc = result.Response.Response.StatusCode 582 } 583 tracing.EndSpan(ctx, sc, err) 584 }() 585 } 586 req, err := client.GetRemoteDesktopPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate) 587 if err != nil { 588 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", nil, "Failure preparing request") 589 return 590 } 591 592 resp, err := client.GetRemoteDesktopSender(req) 593 if err != nil { 594 result.Response = autorest.Response{Response: resp} 595 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", resp, "Failure sending request") 596 return 597 } 598 599 result, err = client.GetRemoteDesktopResponder(resp) 600 if err != nil { 601 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", resp, "Failure responding to request") 602 return 603 } 604 605 return 606} 607 608// GetRemoteDesktopPreparer prepares the GetRemoteDesktop request. 609func (client ComputeNodeClient) GetRemoteDesktopPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 610 pathParameters := map[string]interface{}{ 611 "nodeId": autorest.Encode("path", nodeID), 612 "poolId": autorest.Encode("path", poolID), 613 } 614 615 const APIVersion = "2017-05-01.5.0" 616 queryParameters := map[string]interface{}{ 617 "api-version": APIVersion, 618 } 619 if timeout != nil { 620 queryParameters["timeout"] = autorest.Encode("query", *timeout) 621 } else { 622 queryParameters["timeout"] = autorest.Encode("query", 30) 623 } 624 625 preparer := autorest.CreatePreparer( 626 autorest.AsGet(), 627 autorest.WithBaseURL(client.BaseURI), 628 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/rdp", pathParameters), 629 autorest.WithQueryParameters(queryParameters)) 630 if clientRequestID != nil { 631 preparer = autorest.DecoratePreparer(preparer, 632 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 633 } 634 if returnClientRequestID != nil { 635 preparer = autorest.DecoratePreparer(preparer, 636 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 637 } else { 638 preparer = autorest.DecoratePreparer(preparer, 639 autorest.WithHeader("return-client-request-id", autorest.String(false))) 640 } 641 if ocpDate != nil { 642 preparer = autorest.DecoratePreparer(preparer, 643 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 644 } 645 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 646} 647 648// GetRemoteDesktopSender sends the GetRemoteDesktop request. The method will close the 649// http.Response Body if it receives an error. 650func (client ComputeNodeClient) GetRemoteDesktopSender(req *http.Request) (*http.Response, error) { 651 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 652} 653 654// GetRemoteDesktopResponder handles the response to the GetRemoteDesktop request. The method always 655// closes the http.Response Body. 656func (client ComputeNodeClient) GetRemoteDesktopResponder(resp *http.Response) (result ReadCloser, err error) { 657 result.Value = &resp.Body 658 err = autorest.Respond( 659 resp, 660 azure.WithErrorUnlessStatusCode(http.StatusOK)) 661 result.Response = autorest.Response{Response: resp} 662 return 663} 664 665// GetRemoteLoginSettings before you can remotely login to a node using the remote login settings, you must create a 666// user account on the node. This API can be invoked only on pools created with the virtual machine configuration 667// property. 668// Parameters: 669// poolID - the ID of the pool that contains the compute node. 670// nodeID - the ID of the compute node for which to obtain the remote login settings. 671// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 672// seconds. 673// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 674// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 675// returnClientRequestID - whether the server should return the client-request-id in the response. 676// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 677// time; set it explicitly if you are calling the REST API directly. 678func (client ComputeNodeClient) GetRemoteLoginSettings(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNodeGetRemoteLoginSettingsResult, err error) { 679 if tracing.IsEnabled() { 680 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.GetRemoteLoginSettings") 681 defer func() { 682 sc := -1 683 if result.Response.Response != nil { 684 sc = result.Response.Response.StatusCode 685 } 686 tracing.EndSpan(ctx, sc, err) 687 }() 688 } 689 req, err := client.GetRemoteLoginSettingsPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate) 690 if err != nil { 691 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteLoginSettings", nil, "Failure preparing request") 692 return 693 } 694 695 resp, err := client.GetRemoteLoginSettingsSender(req) 696 if err != nil { 697 result.Response = autorest.Response{Response: resp} 698 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteLoginSettings", resp, "Failure sending request") 699 return 700 } 701 702 result, err = client.GetRemoteLoginSettingsResponder(resp) 703 if err != nil { 704 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteLoginSettings", resp, "Failure responding to request") 705 return 706 } 707 708 return 709} 710 711// GetRemoteLoginSettingsPreparer prepares the GetRemoteLoginSettings request. 712func (client ComputeNodeClient) GetRemoteLoginSettingsPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 713 pathParameters := map[string]interface{}{ 714 "nodeId": autorest.Encode("path", nodeID), 715 "poolId": autorest.Encode("path", poolID), 716 } 717 718 const APIVersion = "2017-05-01.5.0" 719 queryParameters := map[string]interface{}{ 720 "api-version": APIVersion, 721 } 722 if timeout != nil { 723 queryParameters["timeout"] = autorest.Encode("query", *timeout) 724 } else { 725 queryParameters["timeout"] = autorest.Encode("query", 30) 726 } 727 728 preparer := autorest.CreatePreparer( 729 autorest.AsGet(), 730 autorest.WithBaseURL(client.BaseURI), 731 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/remoteloginsettings", pathParameters), 732 autorest.WithQueryParameters(queryParameters)) 733 if clientRequestID != nil { 734 preparer = autorest.DecoratePreparer(preparer, 735 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 736 } 737 if returnClientRequestID != nil { 738 preparer = autorest.DecoratePreparer(preparer, 739 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 740 } else { 741 preparer = autorest.DecoratePreparer(preparer, 742 autorest.WithHeader("return-client-request-id", autorest.String(false))) 743 } 744 if ocpDate != nil { 745 preparer = autorest.DecoratePreparer(preparer, 746 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 747 } 748 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 749} 750 751// GetRemoteLoginSettingsSender sends the GetRemoteLoginSettings request. The method will close the 752// http.Response Body if it receives an error. 753func (client ComputeNodeClient) GetRemoteLoginSettingsSender(req *http.Request) (*http.Response, error) { 754 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 755} 756 757// GetRemoteLoginSettingsResponder handles the response to the GetRemoteLoginSettings request. The method always 758// closes the http.Response Body. 759func (client ComputeNodeClient) GetRemoteLoginSettingsResponder(resp *http.Response) (result ComputeNodeGetRemoteLoginSettingsResult, err error) { 760 err = autorest.Respond( 761 resp, 762 azure.WithErrorUnlessStatusCode(http.StatusOK), 763 autorest.ByUnmarshallingJSON(&result), 764 autorest.ByClosing()) 765 result.Response = autorest.Response{Response: resp} 766 return 767} 768 769// List sends the list request. 770// Parameters: 771// poolID - the ID of the pool from which you want to list nodes. 772// filter - an OData $filter clause.. 773// selectParameter - an OData $select clause. 774// maxResults - the maximum number of items to return in the response. A maximum of 1000 nodes can be returned. 775// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 776// seconds. 777// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 778// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 779// returnClientRequestID - whether the server should return the client-request-id in the response. 780// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 781// time; set it explicitly if you are calling the REST API directly. 782func (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) { 783 if tracing.IsEnabled() { 784 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.List") 785 defer func() { 786 sc := -1 787 if result.cnlr.Response.Response != nil { 788 sc = result.cnlr.Response.Response.StatusCode 789 } 790 tracing.EndSpan(ctx, sc, err) 791 }() 792 } 793 if err := validation.Validate([]validation.Validation{ 794 {TargetValue: maxResults, 795 Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false, 796 Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 797 {Target: "maxResults", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 798 }}}}}); err != nil { 799 return result, validation.NewError("batch.ComputeNodeClient", "List", err.Error()) 800 } 801 802 result.fn = client.listNextResults 803 req, err := client.ListPreparer(ctx, poolID, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 804 if err != nil { 805 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", nil, "Failure preparing request") 806 return 807 } 808 809 resp, err := client.ListSender(req) 810 if err != nil { 811 result.cnlr.Response = autorest.Response{Response: resp} 812 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", resp, "Failure sending request") 813 return 814 } 815 816 result.cnlr, err = client.ListResponder(resp) 817 if err != nil { 818 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", resp, "Failure responding to request") 819 return 820 } 821 if result.cnlr.hasNextLink() && result.cnlr.IsEmpty() { 822 err = result.NextWithContext(ctx) 823 return 824 } 825 826 return 827} 828 829// ListPreparer prepares the List request. 830func (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) { 831 pathParameters := map[string]interface{}{ 832 "poolId": autorest.Encode("path", poolID), 833 } 834 835 const APIVersion = "2017-05-01.5.0" 836 queryParameters := map[string]interface{}{ 837 "api-version": APIVersion, 838 } 839 if len(filter) > 0 { 840 queryParameters["$filter"] = autorest.Encode("query", filter) 841 } 842 if len(selectParameter) > 0 { 843 queryParameters["$select"] = autorest.Encode("query", selectParameter) 844 } 845 if maxResults != nil { 846 queryParameters["maxresults"] = autorest.Encode("query", *maxResults) 847 } else { 848 queryParameters["maxresults"] = autorest.Encode("query", 1000) 849 } 850 if timeout != nil { 851 queryParameters["timeout"] = autorest.Encode("query", *timeout) 852 } else { 853 queryParameters["timeout"] = autorest.Encode("query", 30) 854 } 855 856 preparer := autorest.CreatePreparer( 857 autorest.AsGet(), 858 autorest.WithBaseURL(client.BaseURI), 859 autorest.WithPathParameters("/pools/{poolId}/nodes", pathParameters), 860 autorest.WithQueryParameters(queryParameters)) 861 if clientRequestID != nil { 862 preparer = autorest.DecoratePreparer(preparer, 863 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 864 } 865 if returnClientRequestID != nil { 866 preparer = autorest.DecoratePreparer(preparer, 867 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 868 } else { 869 preparer = autorest.DecoratePreparer(preparer, 870 autorest.WithHeader("return-client-request-id", autorest.String(false))) 871 } 872 if ocpDate != nil { 873 preparer = autorest.DecoratePreparer(preparer, 874 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 875 } 876 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 877} 878 879// ListSender sends the List request. The method will close the 880// http.Response Body if it receives an error. 881func (client ComputeNodeClient) ListSender(req *http.Request) (*http.Response, error) { 882 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 883} 884 885// ListResponder handles the response to the List request. The method always 886// closes the http.Response Body. 887func (client ComputeNodeClient) ListResponder(resp *http.Response) (result ComputeNodeListResult, err error) { 888 err = autorest.Respond( 889 resp, 890 azure.WithErrorUnlessStatusCode(http.StatusOK), 891 autorest.ByUnmarshallingJSON(&result), 892 autorest.ByClosing()) 893 result.Response = autorest.Response{Response: resp} 894 return 895} 896 897// listNextResults retrieves the next set of results, if any. 898func (client ComputeNodeClient) listNextResults(ctx context.Context, lastResults ComputeNodeListResult) (result ComputeNodeListResult, err error) { 899 req, err := lastResults.computeNodeListResultPreparer(ctx) 900 if err != nil { 901 return result, autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", nil, "Failure preparing next results request") 902 } 903 if req == nil { 904 return 905 } 906 resp, err := client.ListSender(req) 907 if err != nil { 908 result.Response = autorest.Response{Response: resp} 909 return result, autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", resp, "Failure sending next results request") 910 } 911 result, err = client.ListResponder(resp) 912 if err != nil { 913 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", resp, "Failure responding to next results request") 914 } 915 return 916} 917 918// ListComplete enumerates all values, automatically crossing page boundaries as required. 919func (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) { 920 if tracing.IsEnabled() { 921 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.List") 922 defer func() { 923 sc := -1 924 if result.Response().Response.Response != nil { 925 sc = result.page.Response().Response.Response.StatusCode 926 } 927 tracing.EndSpan(ctx, sc, err) 928 }() 929 } 930 result.page, err = client.List(ctx, poolID, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 931 return 932} 933 934// Reboot you can restart a node only if it is in an idle or running state. 935// Parameters: 936// poolID - the ID of the pool that contains the compute node. 937// nodeID - the ID of the compute node that you want to restart. 938// nodeRebootParameter - the parameters for the request. 939// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 940// seconds. 941// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 942// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 943// returnClientRequestID - whether the server should return the client-request-id in the response. 944// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 945// time; set it explicitly if you are calling the REST API directly. 946func (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) { 947 if tracing.IsEnabled() { 948 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.Reboot") 949 defer func() { 950 sc := -1 951 if result.Response != nil { 952 sc = result.Response.StatusCode 953 } 954 tracing.EndSpan(ctx, sc, err) 955 }() 956 } 957 req, err := client.RebootPreparer(ctx, poolID, nodeID, nodeRebootParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 958 if err != nil { 959 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", nil, "Failure preparing request") 960 return 961 } 962 963 resp, err := client.RebootSender(req) 964 if err != nil { 965 result.Response = resp 966 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", resp, "Failure sending request") 967 return 968 } 969 970 result, err = client.RebootResponder(resp) 971 if err != nil { 972 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", resp, "Failure responding to request") 973 return 974 } 975 976 return 977} 978 979// RebootPreparer prepares the Reboot request. 980func (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) { 981 pathParameters := map[string]interface{}{ 982 "nodeId": autorest.Encode("path", nodeID), 983 "poolId": autorest.Encode("path", poolID), 984 } 985 986 const APIVersion = "2017-05-01.5.0" 987 queryParameters := map[string]interface{}{ 988 "api-version": APIVersion, 989 } 990 if timeout != nil { 991 queryParameters["timeout"] = autorest.Encode("query", *timeout) 992 } else { 993 queryParameters["timeout"] = autorest.Encode("query", 30) 994 } 995 996 preparer := autorest.CreatePreparer( 997 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 998 autorest.AsPost(), 999 autorest.WithBaseURL(client.BaseURI), 1000 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/reboot", pathParameters), 1001 autorest.WithQueryParameters(queryParameters)) 1002 if nodeRebootParameter != nil { 1003 preparer = autorest.DecoratePreparer(preparer, 1004 autorest.WithJSON(nodeRebootParameter)) 1005 } 1006 if clientRequestID != nil { 1007 preparer = autorest.DecoratePreparer(preparer, 1008 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1009 } 1010 if returnClientRequestID != nil { 1011 preparer = autorest.DecoratePreparer(preparer, 1012 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1013 } else { 1014 preparer = autorest.DecoratePreparer(preparer, 1015 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1016 } 1017 if ocpDate != nil { 1018 preparer = autorest.DecoratePreparer(preparer, 1019 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1020 } 1021 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1022} 1023 1024// RebootSender sends the Reboot request. The method will close the 1025// http.Response Body if it receives an error. 1026func (client ComputeNodeClient) RebootSender(req *http.Request) (*http.Response, error) { 1027 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1028} 1029 1030// RebootResponder handles the response to the Reboot request. The method always 1031// closes the http.Response Body. 1032func (client ComputeNodeClient) RebootResponder(resp *http.Response) (result autorest.Response, err error) { 1033 err = autorest.Respond( 1034 resp, 1035 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1036 autorest.ByClosing()) 1037 result.Response = resp 1038 return 1039} 1040 1041// Reimage you can reinstall the operating system on a node only if it is in an idle or running state. This API can be 1042// invoked only on pools created with the cloud service configuration property. 1043// Parameters: 1044// poolID - the ID of the pool that contains the compute node. 1045// nodeID - the ID of the compute node that you want to restart. 1046// nodeReimageParameter - the parameters for the request. 1047// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 1048// seconds. 1049// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 1050// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 1051// returnClientRequestID - whether the server should return the client-request-id in the response. 1052// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 1053// time; set it explicitly if you are calling the REST API directly. 1054func (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) { 1055 if tracing.IsEnabled() { 1056 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.Reimage") 1057 defer func() { 1058 sc := -1 1059 if result.Response != nil { 1060 sc = result.Response.StatusCode 1061 } 1062 tracing.EndSpan(ctx, sc, err) 1063 }() 1064 } 1065 req, err := client.ReimagePreparer(ctx, poolID, nodeID, nodeReimageParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 1066 if err != nil { 1067 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", nil, "Failure preparing request") 1068 return 1069 } 1070 1071 resp, err := client.ReimageSender(req) 1072 if err != nil { 1073 result.Response = resp 1074 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", resp, "Failure sending request") 1075 return 1076 } 1077 1078 result, err = client.ReimageResponder(resp) 1079 if err != nil { 1080 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", resp, "Failure responding to request") 1081 return 1082 } 1083 1084 return 1085} 1086 1087// ReimagePreparer prepares the Reimage request. 1088func (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) { 1089 pathParameters := map[string]interface{}{ 1090 "nodeId": autorest.Encode("path", nodeID), 1091 "poolId": autorest.Encode("path", poolID), 1092 } 1093 1094 const APIVersion = "2017-05-01.5.0" 1095 queryParameters := map[string]interface{}{ 1096 "api-version": APIVersion, 1097 } 1098 if timeout != nil { 1099 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1100 } else { 1101 queryParameters["timeout"] = autorest.Encode("query", 30) 1102 } 1103 1104 preparer := autorest.CreatePreparer( 1105 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 1106 autorest.AsPost(), 1107 autorest.WithBaseURL(client.BaseURI), 1108 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/reimage", pathParameters), 1109 autorest.WithQueryParameters(queryParameters)) 1110 if nodeReimageParameter != nil { 1111 preparer = autorest.DecoratePreparer(preparer, 1112 autorest.WithJSON(nodeReimageParameter)) 1113 } 1114 if clientRequestID != nil { 1115 preparer = autorest.DecoratePreparer(preparer, 1116 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1117 } 1118 if returnClientRequestID != nil { 1119 preparer = autorest.DecoratePreparer(preparer, 1120 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1121 } else { 1122 preparer = autorest.DecoratePreparer(preparer, 1123 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1124 } 1125 if ocpDate != nil { 1126 preparer = autorest.DecoratePreparer(preparer, 1127 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1128 } 1129 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1130} 1131 1132// ReimageSender sends the Reimage request. The method will close the 1133// http.Response Body if it receives an error. 1134func (client ComputeNodeClient) ReimageSender(req *http.Request) (*http.Response, error) { 1135 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1136} 1137 1138// ReimageResponder handles the response to the Reimage request. The method always 1139// closes the http.Response Body. 1140func (client ComputeNodeClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) { 1141 err = autorest.Respond( 1142 resp, 1143 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1144 autorest.ByClosing()) 1145 result.Response = resp 1146 return 1147} 1148 1149// UpdateUser this operation replaces of all the updatable properties of the account. For example, if the expiryTime 1150// element is not specified, the current value is replaced with the default value, not left unmodified. You can update 1151// a user account on a node only when it is in the idle or running state. 1152// Parameters: 1153// poolID - the ID of the pool that contains the compute node. 1154// nodeID - the ID of the machine on which you want to update a user account. 1155// userName - the name of the user account to update. 1156// nodeUpdateUserParameter - the parameters for the request. 1157// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 1158// seconds. 1159// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 1160// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 1161// returnClientRequestID - whether the server should return the client-request-id in the response. 1162// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 1163// time; set it explicitly if you are calling the REST API directly. 1164func (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) { 1165 if tracing.IsEnabled() { 1166 ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.UpdateUser") 1167 defer func() { 1168 sc := -1 1169 if result.Response != nil { 1170 sc = result.Response.StatusCode 1171 } 1172 tracing.EndSpan(ctx, sc, err) 1173 }() 1174 } 1175 req, err := client.UpdateUserPreparer(ctx, poolID, nodeID, userName, nodeUpdateUserParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 1176 if err != nil { 1177 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", nil, "Failure preparing request") 1178 return 1179 } 1180 1181 resp, err := client.UpdateUserSender(req) 1182 if err != nil { 1183 result.Response = resp 1184 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", resp, "Failure sending request") 1185 return 1186 } 1187 1188 result, err = client.UpdateUserResponder(resp) 1189 if err != nil { 1190 err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", resp, "Failure responding to request") 1191 return 1192 } 1193 1194 return 1195} 1196 1197// UpdateUserPreparer prepares the UpdateUser request. 1198func (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) { 1199 pathParameters := map[string]interface{}{ 1200 "nodeId": autorest.Encode("path", nodeID), 1201 "poolId": autorest.Encode("path", poolID), 1202 "userName": autorest.Encode("path", userName), 1203 } 1204 1205 const APIVersion = "2017-05-01.5.0" 1206 queryParameters := map[string]interface{}{ 1207 "api-version": APIVersion, 1208 } 1209 if timeout != nil { 1210 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1211 } else { 1212 queryParameters["timeout"] = autorest.Encode("query", 30) 1213 } 1214 1215 preparer := autorest.CreatePreparer( 1216 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 1217 autorest.AsPut(), 1218 autorest.WithBaseURL(client.BaseURI), 1219 autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/users/{userName}", pathParameters), 1220 autorest.WithJSON(nodeUpdateUserParameter), 1221 autorest.WithQueryParameters(queryParameters)) 1222 if clientRequestID != nil { 1223 preparer = autorest.DecoratePreparer(preparer, 1224 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1225 } 1226 if returnClientRequestID != nil { 1227 preparer = autorest.DecoratePreparer(preparer, 1228 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1229 } else { 1230 preparer = autorest.DecoratePreparer(preparer, 1231 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1232 } 1233 if ocpDate != nil { 1234 preparer = autorest.DecoratePreparer(preparer, 1235 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1236 } 1237 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1238} 1239 1240// UpdateUserSender sends the UpdateUser request. The method will close the 1241// http.Response Body if it receives an error. 1242func (client ComputeNodeClient) UpdateUserSender(req *http.Request) (*http.Response, error) { 1243 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1244} 1245 1246// UpdateUserResponder handles the response to the UpdateUser request. The method always 1247// closes the http.Response Body. 1248func (client ComputeNodeClient) UpdateUserResponder(resp *http.Response) (result autorest.Response, err error) { 1249 err = autorest.Respond( 1250 resp, 1251 azure.WithErrorUnlessStatusCode(http.StatusOK), 1252 autorest.ByClosing()) 1253 result.Response = resp 1254 return 1255} 1256