1package compute 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/autorest/validation" 25 "github.com/Azure/go-autorest/tracing" 26 "net/http" 27) 28 29// VirtualMachineScaleSetVMsClient is the compute Client 30type VirtualMachineScaleSetVMsClient struct { 31 BaseClient 32} 33 34// NewVirtualMachineScaleSetVMsClient creates an instance of the VirtualMachineScaleSetVMsClient client. 35func NewVirtualMachineScaleSetVMsClient(subscriptionID string) VirtualMachineScaleSetVMsClient { 36 return NewVirtualMachineScaleSetVMsClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewVirtualMachineScaleSetVMsClientWithBaseURI creates an instance of the VirtualMachineScaleSetVMsClient client. 40func NewVirtualMachineScaleSetVMsClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineScaleSetVMsClient { 41 return VirtualMachineScaleSetVMsClient{NewWithBaseURI(baseURI, subscriptionID)} 42} 43 44// Deallocate deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and releases the 45// compute resources it uses. You are not billed for the compute resources of this virtual machine once it is 46// deallocated. 47// Parameters: 48// resourceGroupName - the name of the resource group. 49// VMScaleSetName - the name of the VM scale set. 50// instanceID - the instance ID of the virtual machine. 51func (client VirtualMachineScaleSetVMsClient) Deallocate(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMsDeallocateFuture, err error) { 52 if tracing.IsEnabled() { 53 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.Deallocate") 54 defer func() { 55 sc := -1 56 if result.Response() != nil { 57 sc = result.Response().StatusCode 58 } 59 tracing.EndSpan(ctx, sc, err) 60 }() 61 } 62 req, err := client.DeallocatePreparer(ctx, resourceGroupName, VMScaleSetName, instanceID) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", nil, "Failure preparing request") 65 return 66 } 67 68 result, err = client.DeallocateSender(req) 69 if err != nil { 70 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", result.Response(), "Failure sending request") 71 return 72 } 73 74 return 75} 76 77// DeallocatePreparer prepares the Deallocate request. 78func (client VirtualMachineScaleSetVMsClient) DeallocatePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) { 79 pathParameters := map[string]interface{}{ 80 "instanceId": autorest.Encode("path", instanceID), 81 "resourceGroupName": autorest.Encode("path", resourceGroupName), 82 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 83 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 84 } 85 86 const APIVersion = "2018-10-01" 87 queryParameters := map[string]interface{}{ 88 "api-version": APIVersion, 89 } 90 91 preparer := autorest.CreatePreparer( 92 autorest.AsPost(), 93 autorest.WithBaseURL(client.BaseURI), 94 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate", pathParameters), 95 autorest.WithQueryParameters(queryParameters)) 96 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 97} 98 99// DeallocateSender sends the Deallocate request. The method will close the 100// http.Response Body if it receives an error. 101func (client VirtualMachineScaleSetVMsClient) DeallocateSender(req *http.Request) (future VirtualMachineScaleSetVMsDeallocateFuture, err error) { 102 var resp *http.Response 103 resp, err = autorest.SendWithSender(client, req, 104 azure.DoRetryWithRegistration(client.Client)) 105 if err != nil { 106 return 107 } 108 future.Future, err = azure.NewFutureFromResponse(resp) 109 return 110} 111 112// DeallocateResponder handles the response to the Deallocate request. The method always 113// closes the http.Response Body. 114func (client VirtualMachineScaleSetVMsClient) DeallocateResponder(resp *http.Response) (result autorest.Response, err error) { 115 err = autorest.Respond( 116 resp, 117 client.ByInspecting(), 118 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 119 autorest.ByClosing()) 120 result.Response = resp 121 return 122} 123 124// Delete deletes a virtual machine from a VM scale set. 125// Parameters: 126// resourceGroupName - the name of the resource group. 127// VMScaleSetName - the name of the VM scale set. 128// instanceID - the instance ID of the virtual machine. 129func (client VirtualMachineScaleSetVMsClient) Delete(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMsDeleteFuture, err error) { 130 if tracing.IsEnabled() { 131 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.Delete") 132 defer func() { 133 sc := -1 134 if result.Response() != nil { 135 sc = result.Response().StatusCode 136 } 137 tracing.EndSpan(ctx, sc, err) 138 }() 139 } 140 req, err := client.DeletePreparer(ctx, resourceGroupName, VMScaleSetName, instanceID) 141 if err != nil { 142 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", nil, "Failure preparing request") 143 return 144 } 145 146 result, err = client.DeleteSender(req) 147 if err != nil { 148 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", result.Response(), "Failure sending request") 149 return 150 } 151 152 return 153} 154 155// DeletePreparer prepares the Delete request. 156func (client VirtualMachineScaleSetVMsClient) DeletePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) { 157 pathParameters := map[string]interface{}{ 158 "instanceId": autorest.Encode("path", instanceID), 159 "resourceGroupName": autorest.Encode("path", resourceGroupName), 160 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 161 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 162 } 163 164 const APIVersion = "2018-10-01" 165 queryParameters := map[string]interface{}{ 166 "api-version": APIVersion, 167 } 168 169 preparer := autorest.CreatePreparer( 170 autorest.AsDelete(), 171 autorest.WithBaseURL(client.BaseURI), 172 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", pathParameters), 173 autorest.WithQueryParameters(queryParameters)) 174 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 175} 176 177// DeleteSender sends the Delete request. The method will close the 178// http.Response Body if it receives an error. 179func (client VirtualMachineScaleSetVMsClient) DeleteSender(req *http.Request) (future VirtualMachineScaleSetVMsDeleteFuture, err error) { 180 var resp *http.Response 181 resp, err = autorest.SendWithSender(client, req, 182 azure.DoRetryWithRegistration(client.Client)) 183 if err != nil { 184 return 185 } 186 future.Future, err = azure.NewFutureFromResponse(resp) 187 return 188} 189 190// DeleteResponder handles the response to the Delete request. The method always 191// closes the http.Response Body. 192func (client VirtualMachineScaleSetVMsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 193 err = autorest.Respond( 194 resp, 195 client.ByInspecting(), 196 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 197 autorest.ByClosing()) 198 result.Response = resp 199 return 200} 201 202// Get gets a virtual machine from a VM scale set. 203// Parameters: 204// resourceGroupName - the name of the resource group. 205// VMScaleSetName - the name of the VM scale set. 206// instanceID - the instance ID of the virtual machine. 207func (client VirtualMachineScaleSetVMsClient) Get(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVM, err error) { 208 if tracing.IsEnabled() { 209 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.Get") 210 defer func() { 211 sc := -1 212 if result.Response.Response != nil { 213 sc = result.Response.Response.StatusCode 214 } 215 tracing.EndSpan(ctx, sc, err) 216 }() 217 } 218 req, err := client.GetPreparer(ctx, resourceGroupName, VMScaleSetName, instanceID) 219 if err != nil { 220 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", nil, "Failure preparing request") 221 return 222 } 223 224 resp, err := client.GetSender(req) 225 if err != nil { 226 result.Response = autorest.Response{Response: resp} 227 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", resp, "Failure sending request") 228 return 229 } 230 231 result, err = client.GetResponder(resp) 232 if err != nil { 233 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", resp, "Failure responding to request") 234 } 235 236 return 237} 238 239// GetPreparer prepares the Get request. 240func (client VirtualMachineScaleSetVMsClient) GetPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) { 241 pathParameters := map[string]interface{}{ 242 "instanceId": autorest.Encode("path", instanceID), 243 "resourceGroupName": autorest.Encode("path", resourceGroupName), 244 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 245 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 246 } 247 248 const APIVersion = "2018-10-01" 249 queryParameters := map[string]interface{}{ 250 "api-version": APIVersion, 251 } 252 253 preparer := autorest.CreatePreparer( 254 autorest.AsGet(), 255 autorest.WithBaseURL(client.BaseURI), 256 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", pathParameters), 257 autorest.WithQueryParameters(queryParameters)) 258 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 259} 260 261// GetSender sends the Get request. The method will close the 262// http.Response Body if it receives an error. 263func (client VirtualMachineScaleSetVMsClient) GetSender(req *http.Request) (*http.Response, error) { 264 return autorest.SendWithSender(client, req, 265 azure.DoRetryWithRegistration(client.Client)) 266} 267 268// GetResponder handles the response to the Get request. The method always 269// closes the http.Response Body. 270func (client VirtualMachineScaleSetVMsClient) GetResponder(resp *http.Response) (result VirtualMachineScaleSetVM, err error) { 271 err = autorest.Respond( 272 resp, 273 client.ByInspecting(), 274 azure.WithErrorUnlessStatusCode(http.StatusOK), 275 autorest.ByUnmarshallingJSON(&result), 276 autorest.ByClosing()) 277 result.Response = autorest.Response{Response: resp} 278 return 279} 280 281// GetInstanceView gets the status of a virtual machine from a VM scale set. 282// Parameters: 283// resourceGroupName - the name of the resource group. 284// VMScaleSetName - the name of the VM scale set. 285// instanceID - the instance ID of the virtual machine. 286func (client VirtualMachineScaleSetVMsClient) GetInstanceView(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMInstanceView, err error) { 287 if tracing.IsEnabled() { 288 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.GetInstanceView") 289 defer func() { 290 sc := -1 291 if result.Response.Response != nil { 292 sc = result.Response.Response.StatusCode 293 } 294 tracing.EndSpan(ctx, sc, err) 295 }() 296 } 297 req, err := client.GetInstanceViewPreparer(ctx, resourceGroupName, VMScaleSetName, instanceID) 298 if err != nil { 299 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", nil, "Failure preparing request") 300 return 301 } 302 303 resp, err := client.GetInstanceViewSender(req) 304 if err != nil { 305 result.Response = autorest.Response{Response: resp} 306 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", resp, "Failure sending request") 307 return 308 } 309 310 result, err = client.GetInstanceViewResponder(resp) 311 if err != nil { 312 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", resp, "Failure responding to request") 313 } 314 315 return 316} 317 318// GetInstanceViewPreparer prepares the GetInstanceView request. 319func (client VirtualMachineScaleSetVMsClient) GetInstanceViewPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) { 320 pathParameters := map[string]interface{}{ 321 "instanceId": autorest.Encode("path", instanceID), 322 "resourceGroupName": autorest.Encode("path", resourceGroupName), 323 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 324 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 325 } 326 327 const APIVersion = "2018-10-01" 328 queryParameters := map[string]interface{}{ 329 "api-version": APIVersion, 330 } 331 332 preparer := autorest.CreatePreparer( 333 autorest.AsGet(), 334 autorest.WithBaseURL(client.BaseURI), 335 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView", pathParameters), 336 autorest.WithQueryParameters(queryParameters)) 337 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 338} 339 340// GetInstanceViewSender sends the GetInstanceView request. The method will close the 341// http.Response Body if it receives an error. 342func (client VirtualMachineScaleSetVMsClient) GetInstanceViewSender(req *http.Request) (*http.Response, error) { 343 return autorest.SendWithSender(client, req, 344 azure.DoRetryWithRegistration(client.Client)) 345} 346 347// GetInstanceViewResponder handles the response to the GetInstanceView request. The method always 348// closes the http.Response Body. 349func (client VirtualMachineScaleSetVMsClient) GetInstanceViewResponder(resp *http.Response) (result VirtualMachineScaleSetVMInstanceView, err error) { 350 err = autorest.Respond( 351 resp, 352 client.ByInspecting(), 353 azure.WithErrorUnlessStatusCode(http.StatusOK), 354 autorest.ByUnmarshallingJSON(&result), 355 autorest.ByClosing()) 356 result.Response = autorest.Response{Response: resp} 357 return 358} 359 360// List gets a list of all virtual machines in a VM scale sets. 361// Parameters: 362// resourceGroupName - the name of the resource group. 363// virtualMachineScaleSetName - the name of the VM scale set. 364// filter - the filter to apply to the operation. 365// selectParameter - the list parameters. 366// expand - the expand expression to apply to the operation. 367func (client VirtualMachineScaleSetVMsClient) List(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, filter string, selectParameter string, expand string) (result VirtualMachineScaleSetVMListResultPage, err error) { 368 if tracing.IsEnabled() { 369 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.List") 370 defer func() { 371 sc := -1 372 if result.vmssvlr.Response.Response != nil { 373 sc = result.vmssvlr.Response.Response.StatusCode 374 } 375 tracing.EndSpan(ctx, sc, err) 376 }() 377 } 378 result.fn = client.listNextResults 379 req, err := client.ListPreparer(ctx, resourceGroupName, virtualMachineScaleSetName, filter, selectParameter, expand) 380 if err != nil { 381 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", nil, "Failure preparing request") 382 return 383 } 384 385 resp, err := client.ListSender(req) 386 if err != nil { 387 result.vmssvlr.Response = autorest.Response{Response: resp} 388 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", resp, "Failure sending request") 389 return 390 } 391 392 result.vmssvlr, err = client.ListResponder(resp) 393 if err != nil { 394 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", resp, "Failure responding to request") 395 } 396 397 return 398} 399 400// ListPreparer prepares the List request. 401func (client VirtualMachineScaleSetVMsClient) ListPreparer(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, filter string, selectParameter string, expand string) (*http.Request, error) { 402 pathParameters := map[string]interface{}{ 403 "resourceGroupName": autorest.Encode("path", resourceGroupName), 404 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 405 "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), 406 } 407 408 const APIVersion = "2018-10-01" 409 queryParameters := map[string]interface{}{ 410 "api-version": APIVersion, 411 } 412 if len(filter) > 0 { 413 queryParameters["$filter"] = autorest.Encode("query", filter) 414 } 415 if len(selectParameter) > 0 { 416 queryParameters["$select"] = autorest.Encode("query", selectParameter) 417 } 418 if len(expand) > 0 { 419 queryParameters["$expand"] = autorest.Encode("query", expand) 420 } 421 422 preparer := autorest.CreatePreparer( 423 autorest.AsGet(), 424 autorest.WithBaseURL(client.BaseURI), 425 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", pathParameters), 426 autorest.WithQueryParameters(queryParameters)) 427 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 428} 429 430// ListSender sends the List request. The method will close the 431// http.Response Body if it receives an error. 432func (client VirtualMachineScaleSetVMsClient) ListSender(req *http.Request) (*http.Response, error) { 433 return autorest.SendWithSender(client, req, 434 azure.DoRetryWithRegistration(client.Client)) 435} 436 437// ListResponder handles the response to the List request. The method always 438// closes the http.Response Body. 439func (client VirtualMachineScaleSetVMsClient) ListResponder(resp *http.Response) (result VirtualMachineScaleSetVMListResult, err error) { 440 err = autorest.Respond( 441 resp, 442 client.ByInspecting(), 443 azure.WithErrorUnlessStatusCode(http.StatusOK), 444 autorest.ByUnmarshallingJSON(&result), 445 autorest.ByClosing()) 446 result.Response = autorest.Response{Response: resp} 447 return 448} 449 450// listNextResults retrieves the next set of results, if any. 451func (client VirtualMachineScaleSetVMsClient) listNextResults(ctx context.Context, lastResults VirtualMachineScaleSetVMListResult) (result VirtualMachineScaleSetVMListResult, err error) { 452 req, err := lastResults.virtualMachineScaleSetVMListResultPreparer(ctx) 453 if err != nil { 454 return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "listNextResults", nil, "Failure preparing next results request") 455 } 456 if req == nil { 457 return 458 } 459 resp, err := client.ListSender(req) 460 if err != nil { 461 result.Response = autorest.Response{Response: resp} 462 return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "listNextResults", resp, "Failure sending next results request") 463 } 464 result, err = client.ListResponder(resp) 465 if err != nil { 466 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "listNextResults", resp, "Failure responding to next results request") 467 } 468 return 469} 470 471// ListComplete enumerates all values, automatically crossing page boundaries as required. 472func (client VirtualMachineScaleSetVMsClient) ListComplete(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, filter string, selectParameter string, expand string) (result VirtualMachineScaleSetVMListResultIterator, err error) { 473 if tracing.IsEnabled() { 474 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.List") 475 defer func() { 476 sc := -1 477 if result.Response().Response.Response != nil { 478 sc = result.page.Response().Response.Response.StatusCode 479 } 480 tracing.EndSpan(ctx, sc, err) 481 }() 482 } 483 result.page, err = client.List(ctx, resourceGroupName, virtualMachineScaleSetName, filter, selectParameter, expand) 484 return 485} 486 487// PerformMaintenance performs maintenance on a virtual machine in a VM scale set. 488// Parameters: 489// resourceGroupName - the name of the resource group. 490// VMScaleSetName - the name of the VM scale set. 491// instanceID - the instance ID of the virtual machine. 492func (client VirtualMachineScaleSetVMsClient) PerformMaintenance(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMsPerformMaintenanceFuture, err error) { 493 if tracing.IsEnabled() { 494 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.PerformMaintenance") 495 defer func() { 496 sc := -1 497 if result.Response() != nil { 498 sc = result.Response().StatusCode 499 } 500 tracing.EndSpan(ctx, sc, err) 501 }() 502 } 503 req, err := client.PerformMaintenancePreparer(ctx, resourceGroupName, VMScaleSetName, instanceID) 504 if err != nil { 505 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PerformMaintenance", nil, "Failure preparing request") 506 return 507 } 508 509 result, err = client.PerformMaintenanceSender(req) 510 if err != nil { 511 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PerformMaintenance", result.Response(), "Failure sending request") 512 return 513 } 514 515 return 516} 517 518// PerformMaintenancePreparer prepares the PerformMaintenance request. 519func (client VirtualMachineScaleSetVMsClient) PerformMaintenancePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) { 520 pathParameters := map[string]interface{}{ 521 "instanceId": autorest.Encode("path", instanceID), 522 "resourceGroupName": autorest.Encode("path", resourceGroupName), 523 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 524 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 525 } 526 527 const APIVersion = "2018-10-01" 528 queryParameters := map[string]interface{}{ 529 "api-version": APIVersion, 530 } 531 532 preparer := autorest.CreatePreparer( 533 autorest.AsPost(), 534 autorest.WithBaseURL(client.BaseURI), 535 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance", pathParameters), 536 autorest.WithQueryParameters(queryParameters)) 537 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 538} 539 540// PerformMaintenanceSender sends the PerformMaintenance request. The method will close the 541// http.Response Body if it receives an error. 542func (client VirtualMachineScaleSetVMsClient) PerformMaintenanceSender(req *http.Request) (future VirtualMachineScaleSetVMsPerformMaintenanceFuture, err error) { 543 var resp *http.Response 544 resp, err = autorest.SendWithSender(client, req, 545 azure.DoRetryWithRegistration(client.Client)) 546 if err != nil { 547 return 548 } 549 future.Future, err = azure.NewFutureFromResponse(resp) 550 return 551} 552 553// PerformMaintenanceResponder handles the response to the PerformMaintenance request. The method always 554// closes the http.Response Body. 555func (client VirtualMachineScaleSetVMsClient) PerformMaintenanceResponder(resp *http.Response) (result autorest.Response, err error) { 556 err = autorest.Respond( 557 resp, 558 client.ByInspecting(), 559 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 560 autorest.ByClosing()) 561 result.Response = resp 562 return 563} 564 565// PowerOff power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and you are 566// getting charged for the resources. Instead, use deallocate to release resources and avoid charges. 567// Parameters: 568// resourceGroupName - the name of the resource group. 569// VMScaleSetName - the name of the VM scale set. 570// instanceID - the instance ID of the virtual machine. 571func (client VirtualMachineScaleSetVMsClient) PowerOff(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMsPowerOffFuture, err error) { 572 if tracing.IsEnabled() { 573 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.PowerOff") 574 defer func() { 575 sc := -1 576 if result.Response() != nil { 577 sc = result.Response().StatusCode 578 } 579 tracing.EndSpan(ctx, sc, err) 580 }() 581 } 582 req, err := client.PowerOffPreparer(ctx, resourceGroupName, VMScaleSetName, instanceID) 583 if err != nil { 584 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", nil, "Failure preparing request") 585 return 586 } 587 588 result, err = client.PowerOffSender(req) 589 if err != nil { 590 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", result.Response(), "Failure sending request") 591 return 592 } 593 594 return 595} 596 597// PowerOffPreparer prepares the PowerOff request. 598func (client VirtualMachineScaleSetVMsClient) PowerOffPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) { 599 pathParameters := map[string]interface{}{ 600 "instanceId": autorest.Encode("path", instanceID), 601 "resourceGroupName": autorest.Encode("path", resourceGroupName), 602 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 603 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 604 } 605 606 const APIVersion = "2018-10-01" 607 queryParameters := map[string]interface{}{ 608 "api-version": APIVersion, 609 } 610 611 preparer := autorest.CreatePreparer( 612 autorest.AsPost(), 613 autorest.WithBaseURL(client.BaseURI), 614 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff", pathParameters), 615 autorest.WithQueryParameters(queryParameters)) 616 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 617} 618 619// PowerOffSender sends the PowerOff request. The method will close the 620// http.Response Body if it receives an error. 621func (client VirtualMachineScaleSetVMsClient) PowerOffSender(req *http.Request) (future VirtualMachineScaleSetVMsPowerOffFuture, err error) { 622 var resp *http.Response 623 resp, err = autorest.SendWithSender(client, req, 624 azure.DoRetryWithRegistration(client.Client)) 625 if err != nil { 626 return 627 } 628 future.Future, err = azure.NewFutureFromResponse(resp) 629 return 630} 631 632// PowerOffResponder handles the response to the PowerOff request. The method always 633// closes the http.Response Body. 634func (client VirtualMachineScaleSetVMsClient) PowerOffResponder(resp *http.Response) (result autorest.Response, err error) { 635 err = autorest.Respond( 636 resp, 637 client.ByInspecting(), 638 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 639 autorest.ByClosing()) 640 result.Response = resp 641 return 642} 643 644// Redeploy redeploys a virtual machine in a VM scale set. 645// Parameters: 646// resourceGroupName - the name of the resource group. 647// VMScaleSetName - the name of the VM scale set. 648// instanceID - the instance ID of the virtual machine. 649func (client VirtualMachineScaleSetVMsClient) Redeploy(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMsRedeployFuture, err error) { 650 if tracing.IsEnabled() { 651 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.Redeploy") 652 defer func() { 653 sc := -1 654 if result.Response() != nil { 655 sc = result.Response().StatusCode 656 } 657 tracing.EndSpan(ctx, sc, err) 658 }() 659 } 660 req, err := client.RedeployPreparer(ctx, resourceGroupName, VMScaleSetName, instanceID) 661 if err != nil { 662 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Redeploy", nil, "Failure preparing request") 663 return 664 } 665 666 result, err = client.RedeploySender(req) 667 if err != nil { 668 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Redeploy", result.Response(), "Failure sending request") 669 return 670 } 671 672 return 673} 674 675// RedeployPreparer prepares the Redeploy request. 676func (client VirtualMachineScaleSetVMsClient) RedeployPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) { 677 pathParameters := map[string]interface{}{ 678 "instanceId": autorest.Encode("path", instanceID), 679 "resourceGroupName": autorest.Encode("path", resourceGroupName), 680 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 681 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 682 } 683 684 const APIVersion = "2018-10-01" 685 queryParameters := map[string]interface{}{ 686 "api-version": APIVersion, 687 } 688 689 preparer := autorest.CreatePreparer( 690 autorest.AsPost(), 691 autorest.WithBaseURL(client.BaseURI), 692 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy", pathParameters), 693 autorest.WithQueryParameters(queryParameters)) 694 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 695} 696 697// RedeploySender sends the Redeploy request. The method will close the 698// http.Response Body if it receives an error. 699func (client VirtualMachineScaleSetVMsClient) RedeploySender(req *http.Request) (future VirtualMachineScaleSetVMsRedeployFuture, err error) { 700 var resp *http.Response 701 resp, err = autorest.SendWithSender(client, req, 702 azure.DoRetryWithRegistration(client.Client)) 703 if err != nil { 704 return 705 } 706 future.Future, err = azure.NewFutureFromResponse(resp) 707 return 708} 709 710// RedeployResponder handles the response to the Redeploy request. The method always 711// closes the http.Response Body. 712func (client VirtualMachineScaleSetVMsClient) RedeployResponder(resp *http.Response) (result autorest.Response, err error) { 713 err = autorest.Respond( 714 resp, 715 client.ByInspecting(), 716 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 717 autorest.ByClosing()) 718 result.Response = resp 719 return 720} 721 722// Reimage reimages (upgrade the operating system) a specific virtual machine in a VM scale set. 723// Parameters: 724// resourceGroupName - the name of the resource group. 725// VMScaleSetName - the name of the VM scale set. 726// instanceID - the instance ID of the virtual machine. 727// VMScaleSetVMReimageInput - parameters for the Reimaging Virtual machine in ScaleSet. 728func (client VirtualMachineScaleSetVMsClient) Reimage(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, VMScaleSetVMReimageInput *VirtualMachineScaleSetVMReimageParameters) (result VirtualMachineScaleSetVMsReimageFuture, err error) { 729 if tracing.IsEnabled() { 730 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.Reimage") 731 defer func() { 732 sc := -1 733 if result.Response() != nil { 734 sc = result.Response().StatusCode 735 } 736 tracing.EndSpan(ctx, sc, err) 737 }() 738 } 739 req, err := client.ReimagePreparer(ctx, resourceGroupName, VMScaleSetName, instanceID, VMScaleSetVMReimageInput) 740 if err != nil { 741 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", nil, "Failure preparing request") 742 return 743 } 744 745 result, err = client.ReimageSender(req) 746 if err != nil { 747 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", result.Response(), "Failure sending request") 748 return 749 } 750 751 return 752} 753 754// ReimagePreparer prepares the Reimage request. 755func (client VirtualMachineScaleSetVMsClient) ReimagePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, VMScaleSetVMReimageInput *VirtualMachineScaleSetVMReimageParameters) (*http.Request, error) { 756 pathParameters := map[string]interface{}{ 757 "instanceId": autorest.Encode("path", instanceID), 758 "resourceGroupName": autorest.Encode("path", resourceGroupName), 759 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 760 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 761 } 762 763 const APIVersion = "2018-10-01" 764 queryParameters := map[string]interface{}{ 765 "api-version": APIVersion, 766 } 767 768 preparer := autorest.CreatePreparer( 769 autorest.AsContentType("application/json; charset=utf-8"), 770 autorest.AsPost(), 771 autorest.WithBaseURL(client.BaseURI), 772 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage", pathParameters), 773 autorest.WithQueryParameters(queryParameters)) 774 if VMScaleSetVMReimageInput != nil { 775 preparer = autorest.DecoratePreparer(preparer, 776 autorest.WithJSON(VMScaleSetVMReimageInput)) 777 } 778 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 779} 780 781// ReimageSender sends the Reimage request. The method will close the 782// http.Response Body if it receives an error. 783func (client VirtualMachineScaleSetVMsClient) ReimageSender(req *http.Request) (future VirtualMachineScaleSetVMsReimageFuture, err error) { 784 var resp *http.Response 785 resp, err = autorest.SendWithSender(client, req, 786 azure.DoRetryWithRegistration(client.Client)) 787 if err != nil { 788 return 789 } 790 future.Future, err = azure.NewFutureFromResponse(resp) 791 return 792} 793 794// ReimageResponder handles the response to the Reimage request. The method always 795// closes the http.Response Body. 796func (client VirtualMachineScaleSetVMsClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) { 797 err = autorest.Respond( 798 resp, 799 client.ByInspecting(), 800 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 801 autorest.ByClosing()) 802 result.Response = resp 803 return 804} 805 806// ReimageAll allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. This 807// operation is only supported for managed disks. 808// Parameters: 809// resourceGroupName - the name of the resource group. 810// VMScaleSetName - the name of the VM scale set. 811// instanceID - the instance ID of the virtual machine. 812func (client VirtualMachineScaleSetVMsClient) ReimageAll(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMsReimageAllFuture, err error) { 813 if tracing.IsEnabled() { 814 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.ReimageAll") 815 defer func() { 816 sc := -1 817 if result.Response() != nil { 818 sc = result.Response().StatusCode 819 } 820 tracing.EndSpan(ctx, sc, err) 821 }() 822 } 823 req, err := client.ReimageAllPreparer(ctx, resourceGroupName, VMScaleSetName, instanceID) 824 if err != nil { 825 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", nil, "Failure preparing request") 826 return 827 } 828 829 result, err = client.ReimageAllSender(req) 830 if err != nil { 831 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", result.Response(), "Failure sending request") 832 return 833 } 834 835 return 836} 837 838// ReimageAllPreparer prepares the ReimageAll request. 839func (client VirtualMachineScaleSetVMsClient) ReimageAllPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) { 840 pathParameters := map[string]interface{}{ 841 "instanceId": autorest.Encode("path", instanceID), 842 "resourceGroupName": autorest.Encode("path", resourceGroupName), 843 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 844 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 845 } 846 847 const APIVersion = "2018-10-01" 848 queryParameters := map[string]interface{}{ 849 "api-version": APIVersion, 850 } 851 852 preparer := autorest.CreatePreparer( 853 autorest.AsPost(), 854 autorest.WithBaseURL(client.BaseURI), 855 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall", pathParameters), 856 autorest.WithQueryParameters(queryParameters)) 857 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 858} 859 860// ReimageAllSender sends the ReimageAll request. The method will close the 861// http.Response Body if it receives an error. 862func (client VirtualMachineScaleSetVMsClient) ReimageAllSender(req *http.Request) (future VirtualMachineScaleSetVMsReimageAllFuture, err error) { 863 var resp *http.Response 864 resp, err = autorest.SendWithSender(client, req, 865 azure.DoRetryWithRegistration(client.Client)) 866 if err != nil { 867 return 868 } 869 future.Future, err = azure.NewFutureFromResponse(resp) 870 return 871} 872 873// ReimageAllResponder handles the response to the ReimageAll request. The method always 874// closes the http.Response Body. 875func (client VirtualMachineScaleSetVMsClient) ReimageAllResponder(resp *http.Response) (result autorest.Response, err error) { 876 err = autorest.Respond( 877 resp, 878 client.ByInspecting(), 879 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 880 autorest.ByClosing()) 881 result.Response = resp 882 return 883} 884 885// Restart restarts a virtual machine in a VM scale set. 886// Parameters: 887// resourceGroupName - the name of the resource group. 888// VMScaleSetName - the name of the VM scale set. 889// instanceID - the instance ID of the virtual machine. 890func (client VirtualMachineScaleSetVMsClient) Restart(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMsRestartFuture, err error) { 891 if tracing.IsEnabled() { 892 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.Restart") 893 defer func() { 894 sc := -1 895 if result.Response() != nil { 896 sc = result.Response().StatusCode 897 } 898 tracing.EndSpan(ctx, sc, err) 899 }() 900 } 901 req, err := client.RestartPreparer(ctx, resourceGroupName, VMScaleSetName, instanceID) 902 if err != nil { 903 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", nil, "Failure preparing request") 904 return 905 } 906 907 result, err = client.RestartSender(req) 908 if err != nil { 909 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", result.Response(), "Failure sending request") 910 return 911 } 912 913 return 914} 915 916// RestartPreparer prepares the Restart request. 917func (client VirtualMachineScaleSetVMsClient) RestartPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) { 918 pathParameters := map[string]interface{}{ 919 "instanceId": autorest.Encode("path", instanceID), 920 "resourceGroupName": autorest.Encode("path", resourceGroupName), 921 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 922 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 923 } 924 925 const APIVersion = "2018-10-01" 926 queryParameters := map[string]interface{}{ 927 "api-version": APIVersion, 928 } 929 930 preparer := autorest.CreatePreparer( 931 autorest.AsPost(), 932 autorest.WithBaseURL(client.BaseURI), 933 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart", pathParameters), 934 autorest.WithQueryParameters(queryParameters)) 935 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 936} 937 938// RestartSender sends the Restart request. The method will close the 939// http.Response Body if it receives an error. 940func (client VirtualMachineScaleSetVMsClient) RestartSender(req *http.Request) (future VirtualMachineScaleSetVMsRestartFuture, err error) { 941 var resp *http.Response 942 resp, err = autorest.SendWithSender(client, req, 943 azure.DoRetryWithRegistration(client.Client)) 944 if err != nil { 945 return 946 } 947 future.Future, err = azure.NewFutureFromResponse(resp) 948 return 949} 950 951// RestartResponder handles the response to the Restart request. The method always 952// closes the http.Response Body. 953func (client VirtualMachineScaleSetVMsClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) { 954 err = autorest.Respond( 955 resp, 956 client.ByInspecting(), 957 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 958 autorest.ByClosing()) 959 result.Response = resp 960 return 961} 962 963// RunCommand run command on a virtual machine in a VM scale set. 964// Parameters: 965// resourceGroupName - the name of the resource group. 966// VMScaleSetName - the name of the VM scale set. 967// instanceID - the instance ID of the virtual machine. 968// parameters - parameters supplied to the Run command operation. 969func (client VirtualMachineScaleSetVMsClient) RunCommand(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, parameters RunCommandInput) (result VirtualMachineScaleSetVMsRunCommandFuture, err error) { 970 if tracing.IsEnabled() { 971 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.RunCommand") 972 defer func() { 973 sc := -1 974 if result.Response() != nil { 975 sc = result.Response().StatusCode 976 } 977 tracing.EndSpan(ctx, sc, err) 978 }() 979 } 980 if err := validation.Validate([]validation.Validation{ 981 {TargetValue: parameters, 982 Constraints: []validation.Constraint{{Target: "parameters.CommandID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 983 return result, validation.NewError("compute.VirtualMachineScaleSetVMsClient", "RunCommand", err.Error()) 984 } 985 986 req, err := client.RunCommandPreparer(ctx, resourceGroupName, VMScaleSetName, instanceID, parameters) 987 if err != nil { 988 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "RunCommand", nil, "Failure preparing request") 989 return 990 } 991 992 result, err = client.RunCommandSender(req) 993 if err != nil { 994 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "RunCommand", result.Response(), "Failure sending request") 995 return 996 } 997 998 return 999} 1000 1001// RunCommandPreparer prepares the RunCommand request. 1002func (client VirtualMachineScaleSetVMsClient) RunCommandPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, parameters RunCommandInput) (*http.Request, error) { 1003 pathParameters := map[string]interface{}{ 1004 "instanceId": autorest.Encode("path", instanceID), 1005 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1006 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1007 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 1008 } 1009 1010 const APIVersion = "2018-10-01" 1011 queryParameters := map[string]interface{}{ 1012 "api-version": APIVersion, 1013 } 1014 1015 preparer := autorest.CreatePreparer( 1016 autorest.AsContentType("application/json; charset=utf-8"), 1017 autorest.AsPost(), 1018 autorest.WithBaseURL(client.BaseURI), 1019 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand", pathParameters), 1020 autorest.WithJSON(parameters), 1021 autorest.WithQueryParameters(queryParameters)) 1022 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1023} 1024 1025// RunCommandSender sends the RunCommand request. The method will close the 1026// http.Response Body if it receives an error. 1027func (client VirtualMachineScaleSetVMsClient) RunCommandSender(req *http.Request) (future VirtualMachineScaleSetVMsRunCommandFuture, err error) { 1028 var resp *http.Response 1029 resp, err = autorest.SendWithSender(client, req, 1030 azure.DoRetryWithRegistration(client.Client)) 1031 if err != nil { 1032 return 1033 } 1034 future.Future, err = azure.NewFutureFromResponse(resp) 1035 return 1036} 1037 1038// RunCommandResponder handles the response to the RunCommand request. The method always 1039// closes the http.Response Body. 1040func (client VirtualMachineScaleSetVMsClient) RunCommandResponder(resp *http.Response) (result RunCommandResult, err error) { 1041 err = autorest.Respond( 1042 resp, 1043 client.ByInspecting(), 1044 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1045 autorest.ByUnmarshallingJSON(&result), 1046 autorest.ByClosing()) 1047 result.Response = autorest.Response{Response: resp} 1048 return 1049} 1050 1051// Start starts a virtual machine in a VM scale set. 1052// Parameters: 1053// resourceGroupName - the name of the resource group. 1054// VMScaleSetName - the name of the VM scale set. 1055// instanceID - the instance ID of the virtual machine. 1056func (client VirtualMachineScaleSetVMsClient) Start(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMsStartFuture, err error) { 1057 if tracing.IsEnabled() { 1058 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.Start") 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.StartPreparer(ctx, resourceGroupName, VMScaleSetName, instanceID) 1068 if err != nil { 1069 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", nil, "Failure preparing request") 1070 return 1071 } 1072 1073 result, err = client.StartSender(req) 1074 if err != nil { 1075 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", result.Response(), "Failure sending request") 1076 return 1077 } 1078 1079 return 1080} 1081 1082// StartPreparer prepares the Start request. 1083func (client VirtualMachineScaleSetVMsClient) StartPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) { 1084 pathParameters := map[string]interface{}{ 1085 "instanceId": autorest.Encode("path", instanceID), 1086 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1087 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1088 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 1089 } 1090 1091 const APIVersion = "2018-10-01" 1092 queryParameters := map[string]interface{}{ 1093 "api-version": APIVersion, 1094 } 1095 1096 preparer := autorest.CreatePreparer( 1097 autorest.AsPost(), 1098 autorest.WithBaseURL(client.BaseURI), 1099 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start", pathParameters), 1100 autorest.WithQueryParameters(queryParameters)) 1101 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1102} 1103 1104// StartSender sends the Start request. The method will close the 1105// http.Response Body if it receives an error. 1106func (client VirtualMachineScaleSetVMsClient) StartSender(req *http.Request) (future VirtualMachineScaleSetVMsStartFuture, err error) { 1107 var resp *http.Response 1108 resp, err = autorest.SendWithSender(client, req, 1109 azure.DoRetryWithRegistration(client.Client)) 1110 if err != nil { 1111 return 1112 } 1113 future.Future, err = azure.NewFutureFromResponse(resp) 1114 return 1115} 1116 1117// StartResponder handles the response to the Start request. The method always 1118// closes the http.Response Body. 1119func (client VirtualMachineScaleSetVMsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { 1120 err = autorest.Respond( 1121 resp, 1122 client.ByInspecting(), 1123 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1124 autorest.ByClosing()) 1125 result.Response = resp 1126 return 1127} 1128 1129// Update updates a virtual machine of a VM scale set. 1130// Parameters: 1131// resourceGroupName - the name of the resource group. 1132// VMScaleSetName - the name of the VM scale set where the extension should be create or updated. 1133// instanceID - the instance ID of the virtual machine. 1134// parameters - parameters supplied to the Update Virtual Machine Scale Sets VM operation. 1135func (client VirtualMachineScaleSetVMsClient) Update(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, parameters VirtualMachineScaleSetVM) (result VirtualMachineScaleSetVMsUpdateFuture, err error) { 1136 if tracing.IsEnabled() { 1137 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMsClient.Update") 1138 defer func() { 1139 sc := -1 1140 if result.Response() != nil { 1141 sc = result.Response().StatusCode 1142 } 1143 tracing.EndSpan(ctx, sc, err) 1144 }() 1145 } 1146 if err := validation.Validate([]validation.Validation{ 1147 {TargetValue: parameters, 1148 Constraints: []validation.Constraint{{Target: "parameters.VirtualMachineScaleSetVMProperties", Name: validation.Null, Rule: false, 1149 Chain: []validation.Constraint{{Target: "parameters.VirtualMachineScaleSetVMProperties.StorageProfile", Name: validation.Null, Rule: false, 1150 Chain: []validation.Constraint{{Target: "parameters.VirtualMachineScaleSetVMProperties.StorageProfile.OsDisk", Name: validation.Null, Rule: false, 1151 Chain: []validation.Constraint{{Target: "parameters.VirtualMachineScaleSetVMProperties.StorageProfile.OsDisk.EncryptionSettings", Name: validation.Null, Rule: false, 1152 Chain: []validation.Constraint{{Target: "parameters.VirtualMachineScaleSetVMProperties.StorageProfile.OsDisk.EncryptionSettings.DiskEncryptionKey", Name: validation.Null, Rule: false, 1153 Chain: []validation.Constraint{{Target: "parameters.VirtualMachineScaleSetVMProperties.StorageProfile.OsDisk.EncryptionSettings.DiskEncryptionKey.SecretURL", Name: validation.Null, Rule: true, Chain: nil}, 1154 {Target: "parameters.VirtualMachineScaleSetVMProperties.StorageProfile.OsDisk.EncryptionSettings.DiskEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil}, 1155 }}, 1156 {Target: "parameters.VirtualMachineScaleSetVMProperties.StorageProfile.OsDisk.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false, 1157 Chain: []validation.Constraint{{Target: "parameters.VirtualMachineScaleSetVMProperties.StorageProfile.OsDisk.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil}, 1158 {Target: "parameters.VirtualMachineScaleSetVMProperties.StorageProfile.OsDisk.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil}, 1159 }}, 1160 }}, 1161 }}, 1162 }}, 1163 }}}}}); err != nil { 1164 return result, validation.NewError("compute.VirtualMachineScaleSetVMsClient", "Update", err.Error()) 1165 } 1166 1167 req, err := client.UpdatePreparer(ctx, resourceGroupName, VMScaleSetName, instanceID, parameters) 1168 if err != nil { 1169 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Update", nil, "Failure preparing request") 1170 return 1171 } 1172 1173 result, err = client.UpdateSender(req) 1174 if err != nil { 1175 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Update", result.Response(), "Failure sending request") 1176 return 1177 } 1178 1179 return 1180} 1181 1182// UpdatePreparer prepares the Update request. 1183func (client VirtualMachineScaleSetVMsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, parameters VirtualMachineScaleSetVM) (*http.Request, error) { 1184 pathParameters := map[string]interface{}{ 1185 "instanceId": autorest.Encode("path", instanceID), 1186 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1187 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1188 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 1189 } 1190 1191 const APIVersion = "2018-10-01" 1192 queryParameters := map[string]interface{}{ 1193 "api-version": APIVersion, 1194 } 1195 1196 preparer := autorest.CreatePreparer( 1197 autorest.AsContentType("application/json; charset=utf-8"), 1198 autorest.AsPut(), 1199 autorest.WithBaseURL(client.BaseURI), 1200 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", pathParameters), 1201 autorest.WithJSON(parameters), 1202 autorest.WithQueryParameters(queryParameters)) 1203 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1204} 1205 1206// UpdateSender sends the Update request. The method will close the 1207// http.Response Body if it receives an error. 1208func (client VirtualMachineScaleSetVMsClient) UpdateSender(req *http.Request) (future VirtualMachineScaleSetVMsUpdateFuture, err error) { 1209 var resp *http.Response 1210 resp, err = autorest.SendWithSender(client, req, 1211 azure.DoRetryWithRegistration(client.Client)) 1212 if err != nil { 1213 return 1214 } 1215 future.Future, err = azure.NewFutureFromResponse(resp) 1216 return 1217} 1218 1219// UpdateResponder handles the response to the Update request. The method always 1220// closes the http.Response Body. 1221func (client VirtualMachineScaleSetVMsClient) UpdateResponder(resp *http.Response) (result VirtualMachineScaleSetVM, err error) { 1222 err = autorest.Respond( 1223 resp, 1224 client.ByInspecting(), 1225 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1226 autorest.ByUnmarshallingJSON(&result), 1227 autorest.ByClosing()) 1228 result.Response = autorest.Response{Response: resp} 1229 return 1230} 1231