1package compute 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/tracing" 14 "net/http" 15) 16 17// VirtualMachineScaleSetVMRunCommandsClient is the compute Client 18type VirtualMachineScaleSetVMRunCommandsClient struct { 19 BaseClient 20} 21 22// NewVirtualMachineScaleSetVMRunCommandsClient creates an instance of the VirtualMachineScaleSetVMRunCommandsClient 23// client. 24func NewVirtualMachineScaleSetVMRunCommandsClient(subscriptionID string) VirtualMachineScaleSetVMRunCommandsClient { 25 return NewVirtualMachineScaleSetVMRunCommandsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewVirtualMachineScaleSetVMRunCommandsClientWithBaseURI creates an instance of the 29// VirtualMachineScaleSetVMRunCommandsClient client using a custom endpoint. Use this when interacting with an Azure 30// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 31func NewVirtualMachineScaleSetVMRunCommandsClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineScaleSetVMRunCommandsClient { 32 return VirtualMachineScaleSetVMRunCommandsClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// CreateOrUpdate the operation to create or update the VMSS VM run command. 36// Parameters: 37// resourceGroupName - the name of the resource group. 38// VMScaleSetName - the name of the VM scale set. 39// instanceID - the instance ID of the virtual machine. 40// runCommandName - the name of the virtual machine run command. 41// runCommand - parameters supplied to the Create Virtual Machine RunCommand operation. 42func (client VirtualMachineScaleSetVMRunCommandsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, runCommandName string, runCommand VirtualMachineRunCommand) (result VirtualMachineScaleSetVMRunCommandsCreateOrUpdateFuture, err error) { 43 if tracing.IsEnabled() { 44 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMRunCommandsClient.CreateOrUpdate") 45 defer func() { 46 sc := -1 47 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 48 sc = result.FutureAPI.Response().StatusCode 49 } 50 tracing.EndSpan(ctx, sc, err) 51 }() 52 } 53 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, VMScaleSetName, instanceID, runCommandName, runCommand) 54 if err != nil { 55 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "CreateOrUpdate", nil, "Failure preparing request") 56 return 57 } 58 59 result, err = client.CreateOrUpdateSender(req) 60 if err != nil { 61 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "CreateOrUpdate", nil, "Failure sending request") 62 return 63 } 64 65 return 66} 67 68// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 69func (client VirtualMachineScaleSetVMRunCommandsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, runCommandName string, runCommand VirtualMachineRunCommand) (*http.Request, error) { 70 pathParameters := map[string]interface{}{ 71 "instanceId": autorest.Encode("path", instanceID), 72 "resourceGroupName": autorest.Encode("path", resourceGroupName), 73 "runCommandName": autorest.Encode("path", runCommandName), 74 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 75 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 76 } 77 78 const APIVersion = "2020-06-01" 79 queryParameters := map[string]interface{}{ 80 "api-version": APIVersion, 81 } 82 83 preparer := autorest.CreatePreparer( 84 autorest.AsContentType("application/json; charset=utf-8"), 85 autorest.AsPut(), 86 autorest.WithBaseURL(client.BaseURI), 87 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", pathParameters), 88 autorest.WithJSON(runCommand), 89 autorest.WithQueryParameters(queryParameters)) 90 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 91} 92 93// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 94// http.Response Body if it receives an error. 95func (client VirtualMachineScaleSetVMRunCommandsClient) CreateOrUpdateSender(req *http.Request) (future VirtualMachineScaleSetVMRunCommandsCreateOrUpdateFuture, err error) { 96 var resp *http.Response 97 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 98 if err != nil { 99 return 100 } 101 var azf azure.Future 102 azf, err = azure.NewFutureFromResponse(resp) 103 future.FutureAPI = &azf 104 future.Result = future.result 105 return 106} 107 108// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 109// closes the http.Response Body. 110func (client VirtualMachineScaleSetVMRunCommandsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualMachineRunCommand, err error) { 111 err = autorest.Respond( 112 resp, 113 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 114 autorest.ByUnmarshallingJSON(&result), 115 autorest.ByClosing()) 116 result.Response = autorest.Response{Response: resp} 117 return 118} 119 120// Delete the operation to delete the VMSS VM run command. 121// Parameters: 122// resourceGroupName - the name of the resource group. 123// VMScaleSetName - the name of the VM scale set. 124// instanceID - the instance ID of the virtual machine. 125// runCommandName - the name of the virtual machine run command. 126func (client VirtualMachineScaleSetVMRunCommandsClient) Delete(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, runCommandName string) (result VirtualMachineScaleSetVMRunCommandsDeleteFuture, err error) { 127 if tracing.IsEnabled() { 128 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMRunCommandsClient.Delete") 129 defer func() { 130 sc := -1 131 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 132 sc = result.FutureAPI.Response().StatusCode 133 } 134 tracing.EndSpan(ctx, sc, err) 135 }() 136 } 137 req, err := client.DeletePreparer(ctx, resourceGroupName, VMScaleSetName, instanceID, runCommandName) 138 if err != nil { 139 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "Delete", nil, "Failure preparing request") 140 return 141 } 142 143 result, err = client.DeleteSender(req) 144 if err != nil { 145 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "Delete", nil, "Failure sending request") 146 return 147 } 148 149 return 150} 151 152// DeletePreparer prepares the Delete request. 153func (client VirtualMachineScaleSetVMRunCommandsClient) DeletePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, runCommandName string) (*http.Request, error) { 154 pathParameters := map[string]interface{}{ 155 "instanceId": autorest.Encode("path", instanceID), 156 "resourceGroupName": autorest.Encode("path", resourceGroupName), 157 "runCommandName": autorest.Encode("path", runCommandName), 158 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 159 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 160 } 161 162 const APIVersion = "2020-06-01" 163 queryParameters := map[string]interface{}{ 164 "api-version": APIVersion, 165 } 166 167 preparer := autorest.CreatePreparer( 168 autorest.AsDelete(), 169 autorest.WithBaseURL(client.BaseURI), 170 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", pathParameters), 171 autorest.WithQueryParameters(queryParameters)) 172 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 173} 174 175// DeleteSender sends the Delete request. The method will close the 176// http.Response Body if it receives an error. 177func (client VirtualMachineScaleSetVMRunCommandsClient) DeleteSender(req *http.Request) (future VirtualMachineScaleSetVMRunCommandsDeleteFuture, err error) { 178 var resp *http.Response 179 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 180 if err != nil { 181 return 182 } 183 var azf azure.Future 184 azf, err = azure.NewFutureFromResponse(resp) 185 future.FutureAPI = &azf 186 future.Result = future.result 187 return 188} 189 190// DeleteResponder handles the response to the Delete request. The method always 191// closes the http.Response Body. 192func (client VirtualMachineScaleSetVMRunCommandsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 193 err = autorest.Respond( 194 resp, 195 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 196 autorest.ByClosing()) 197 result.Response = resp 198 return 199} 200 201// Get the operation to get the VMSS VM run command. 202// Parameters: 203// resourceGroupName - the name of the resource group. 204// VMScaleSetName - the name of the VM scale set. 205// instanceID - the instance ID of the virtual machine. 206// runCommandName - the name of the virtual machine run command. 207// expand - the expand expression to apply on the operation. 208func (client VirtualMachineScaleSetVMRunCommandsClient) Get(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, runCommandName string, expand string) (result VirtualMachineRunCommand, err error) { 209 if tracing.IsEnabled() { 210 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMRunCommandsClient.Get") 211 defer func() { 212 sc := -1 213 if result.Response.Response != nil { 214 sc = result.Response.Response.StatusCode 215 } 216 tracing.EndSpan(ctx, sc, err) 217 }() 218 } 219 req, err := client.GetPreparer(ctx, resourceGroupName, VMScaleSetName, instanceID, runCommandName, expand) 220 if err != nil { 221 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "Get", nil, "Failure preparing request") 222 return 223 } 224 225 resp, err := client.GetSender(req) 226 if err != nil { 227 result.Response = autorest.Response{Response: resp} 228 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "Get", resp, "Failure sending request") 229 return 230 } 231 232 result, err = client.GetResponder(resp) 233 if err != nil { 234 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "Get", resp, "Failure responding to request") 235 return 236 } 237 238 return 239} 240 241// GetPreparer prepares the Get request. 242func (client VirtualMachineScaleSetVMRunCommandsClient) GetPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, runCommandName string, expand string) (*http.Request, error) { 243 pathParameters := map[string]interface{}{ 244 "instanceId": autorest.Encode("path", instanceID), 245 "resourceGroupName": autorest.Encode("path", resourceGroupName), 246 "runCommandName": autorest.Encode("path", runCommandName), 247 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 248 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 249 } 250 251 const APIVersion = "2020-06-01" 252 queryParameters := map[string]interface{}{ 253 "api-version": APIVersion, 254 } 255 if len(expand) > 0 { 256 queryParameters["$expand"] = autorest.Encode("query", expand) 257 } 258 259 preparer := autorest.CreatePreparer( 260 autorest.AsGet(), 261 autorest.WithBaseURL(client.BaseURI), 262 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", pathParameters), 263 autorest.WithQueryParameters(queryParameters)) 264 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 265} 266 267// GetSender sends the Get request. The method will close the 268// http.Response Body if it receives an error. 269func (client VirtualMachineScaleSetVMRunCommandsClient) GetSender(req *http.Request) (*http.Response, error) { 270 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 271} 272 273// GetResponder handles the response to the Get request. The method always 274// closes the http.Response Body. 275func (client VirtualMachineScaleSetVMRunCommandsClient) GetResponder(resp *http.Response) (result VirtualMachineRunCommand, err error) { 276 err = autorest.Respond( 277 resp, 278 azure.WithErrorUnlessStatusCode(http.StatusOK), 279 autorest.ByUnmarshallingJSON(&result), 280 autorest.ByClosing()) 281 result.Response = autorest.Response{Response: resp} 282 return 283} 284 285// List the operation to get all run commands of an instance in Virtual Machine Scaleset. 286// Parameters: 287// resourceGroupName - the name of the resource group. 288// VMScaleSetName - the name of the VM scale set. 289// instanceID - the instance ID of the virtual machine. 290// expand - the expand expression to apply on the operation. 291func (client VirtualMachineScaleSetVMRunCommandsClient) List(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, expand string) (result VirtualMachineRunCommandsListResultPage, err error) { 292 if tracing.IsEnabled() { 293 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMRunCommandsClient.List") 294 defer func() { 295 sc := -1 296 if result.vmrclr.Response.Response != nil { 297 sc = result.vmrclr.Response.Response.StatusCode 298 } 299 tracing.EndSpan(ctx, sc, err) 300 }() 301 } 302 result.fn = client.listNextResults 303 req, err := client.ListPreparer(ctx, resourceGroupName, VMScaleSetName, instanceID, expand) 304 if err != nil { 305 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "List", nil, "Failure preparing request") 306 return 307 } 308 309 resp, err := client.ListSender(req) 310 if err != nil { 311 result.vmrclr.Response = autorest.Response{Response: resp} 312 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "List", resp, "Failure sending request") 313 return 314 } 315 316 result.vmrclr, err = client.ListResponder(resp) 317 if err != nil { 318 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "List", resp, "Failure responding to request") 319 return 320 } 321 if result.vmrclr.hasNextLink() && result.vmrclr.IsEmpty() { 322 err = result.NextWithContext(ctx) 323 return 324 } 325 326 return 327} 328 329// ListPreparer prepares the List request. 330func (client VirtualMachineScaleSetVMRunCommandsClient) ListPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, expand string) (*http.Request, error) { 331 pathParameters := map[string]interface{}{ 332 "instanceId": autorest.Encode("path", instanceID), 333 "resourceGroupName": autorest.Encode("path", resourceGroupName), 334 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 335 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 336 } 337 338 const APIVersion = "2020-06-01" 339 queryParameters := map[string]interface{}{ 340 "api-version": APIVersion, 341 } 342 if len(expand) > 0 { 343 queryParameters["$expand"] = autorest.Encode("query", expand) 344 } 345 346 preparer := autorest.CreatePreparer( 347 autorest.AsGet(), 348 autorest.WithBaseURL(client.BaseURI), 349 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands", pathParameters), 350 autorest.WithQueryParameters(queryParameters)) 351 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 352} 353 354// ListSender sends the List request. The method will close the 355// http.Response Body if it receives an error. 356func (client VirtualMachineScaleSetVMRunCommandsClient) ListSender(req *http.Request) (*http.Response, error) { 357 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 358} 359 360// ListResponder handles the response to the List request. The method always 361// closes the http.Response Body. 362func (client VirtualMachineScaleSetVMRunCommandsClient) ListResponder(resp *http.Response) (result VirtualMachineRunCommandsListResult, err error) { 363 err = autorest.Respond( 364 resp, 365 azure.WithErrorUnlessStatusCode(http.StatusOK), 366 autorest.ByUnmarshallingJSON(&result), 367 autorest.ByClosing()) 368 result.Response = autorest.Response{Response: resp} 369 return 370} 371 372// listNextResults retrieves the next set of results, if any. 373func (client VirtualMachineScaleSetVMRunCommandsClient) listNextResults(ctx context.Context, lastResults VirtualMachineRunCommandsListResult) (result VirtualMachineRunCommandsListResult, err error) { 374 req, err := lastResults.virtualMachineRunCommandsListResultPreparer(ctx) 375 if err != nil { 376 return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "listNextResults", nil, "Failure preparing next results request") 377 } 378 if req == nil { 379 return 380 } 381 resp, err := client.ListSender(req) 382 if err != nil { 383 result.Response = autorest.Response{Response: resp} 384 return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "listNextResults", resp, "Failure sending next results request") 385 } 386 result, err = client.ListResponder(resp) 387 if err != nil { 388 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "listNextResults", resp, "Failure responding to next results request") 389 } 390 return 391} 392 393// ListComplete enumerates all values, automatically crossing page boundaries as required. 394func (client VirtualMachineScaleSetVMRunCommandsClient) ListComplete(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, expand string) (result VirtualMachineRunCommandsListResultIterator, err error) { 395 if tracing.IsEnabled() { 396 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMRunCommandsClient.List") 397 defer func() { 398 sc := -1 399 if result.Response().Response.Response != nil { 400 sc = result.page.Response().Response.Response.StatusCode 401 } 402 tracing.EndSpan(ctx, sc, err) 403 }() 404 } 405 result.page, err = client.List(ctx, resourceGroupName, VMScaleSetName, instanceID, expand) 406 return 407} 408 409// Update the operation to update the VMSS VM run command. 410// Parameters: 411// resourceGroupName - the name of the resource group. 412// VMScaleSetName - the name of the VM scale set. 413// instanceID - the instance ID of the virtual machine. 414// runCommandName - the name of the virtual machine run command. 415// runCommand - parameters supplied to the Update Virtual Machine RunCommand operation. 416func (client VirtualMachineScaleSetVMRunCommandsClient) Update(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, runCommandName string, runCommand VirtualMachineRunCommandUpdate) (result VirtualMachineScaleSetVMRunCommandsUpdateFuture, err error) { 417 if tracing.IsEnabled() { 418 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetVMRunCommandsClient.Update") 419 defer func() { 420 sc := -1 421 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 422 sc = result.FutureAPI.Response().StatusCode 423 } 424 tracing.EndSpan(ctx, sc, err) 425 }() 426 } 427 req, err := client.UpdatePreparer(ctx, resourceGroupName, VMScaleSetName, instanceID, runCommandName, runCommand) 428 if err != nil { 429 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "Update", nil, "Failure preparing request") 430 return 431 } 432 433 result, err = client.UpdateSender(req) 434 if err != nil { 435 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMRunCommandsClient", "Update", nil, "Failure sending request") 436 return 437 } 438 439 return 440} 441 442// UpdatePreparer prepares the Update request. 443func (client VirtualMachineScaleSetVMRunCommandsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, runCommandName string, runCommand VirtualMachineRunCommandUpdate) (*http.Request, error) { 444 pathParameters := map[string]interface{}{ 445 "instanceId": autorest.Encode("path", instanceID), 446 "resourceGroupName": autorest.Encode("path", resourceGroupName), 447 "runCommandName": autorest.Encode("path", runCommandName), 448 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 449 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 450 } 451 452 const APIVersion = "2020-06-01" 453 queryParameters := map[string]interface{}{ 454 "api-version": APIVersion, 455 } 456 457 preparer := autorest.CreatePreparer( 458 autorest.AsContentType("application/json; charset=utf-8"), 459 autorest.AsPatch(), 460 autorest.WithBaseURL(client.BaseURI), 461 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", pathParameters), 462 autorest.WithJSON(runCommand), 463 autorest.WithQueryParameters(queryParameters)) 464 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 465} 466 467// UpdateSender sends the Update request. The method will close the 468// http.Response Body if it receives an error. 469func (client VirtualMachineScaleSetVMRunCommandsClient) UpdateSender(req *http.Request) (future VirtualMachineScaleSetVMRunCommandsUpdateFuture, err error) { 470 var resp *http.Response 471 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 472 if err != nil { 473 return 474 } 475 var azf azure.Future 476 azf, err = azure.NewFutureFromResponse(resp) 477 future.FutureAPI = &azf 478 future.Result = future.result 479 return 480} 481 482// UpdateResponder handles the response to the Update request. The method always 483// closes the http.Response Body. 484func (client VirtualMachineScaleSetVMRunCommandsClient) UpdateResponder(resp *http.Response) (result VirtualMachineRunCommand, err error) { 485 err = autorest.Respond( 486 resp, 487 azure.WithErrorUnlessStatusCode(http.StatusOK), 488 autorest.ByUnmarshallingJSON(&result), 489 autorest.ByClosing()) 490 result.Response = autorest.Response{Response: resp} 491 return 492} 493