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/tracing" 25 "net/http" 26) 27 28// VirtualMachineScaleSetRollingUpgradesClient is the compute Client 29type VirtualMachineScaleSetRollingUpgradesClient struct { 30 BaseClient 31} 32 33// NewVirtualMachineScaleSetRollingUpgradesClient creates an instance of the 34// VirtualMachineScaleSetRollingUpgradesClient client. 35func NewVirtualMachineScaleSetRollingUpgradesClient(subscriptionID string) VirtualMachineScaleSetRollingUpgradesClient { 36 return NewVirtualMachineScaleSetRollingUpgradesClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewVirtualMachineScaleSetRollingUpgradesClientWithBaseURI creates an instance of the 40// VirtualMachineScaleSetRollingUpgradesClient client using a custom endpoint. Use this when interacting with an Azure 41// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 42func NewVirtualMachineScaleSetRollingUpgradesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineScaleSetRollingUpgradesClient { 43 return VirtualMachineScaleSetRollingUpgradesClient{NewWithBaseURI(baseURI, subscriptionID)} 44} 45 46// Cancel cancels the current virtual machine scale set rolling upgrade. 47// Parameters: 48// resourceGroupName - the name of the resource group. 49// VMScaleSetName - the name of the VM scale set. 50func (client VirtualMachineScaleSetRollingUpgradesClient) Cancel(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSetRollingUpgradesCancelFuture, err error) { 51 if tracing.IsEnabled() { 52 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetRollingUpgradesClient.Cancel") 53 defer func() { 54 sc := -1 55 if result.Response() != nil { 56 sc = result.Response().StatusCode 57 } 58 tracing.EndSpan(ctx, sc, err) 59 }() 60 } 61 req, err := client.CancelPreparer(ctx, resourceGroupName, VMScaleSetName) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "Cancel", nil, "Failure preparing request") 64 return 65 } 66 67 result, err = client.CancelSender(req) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "Cancel", result.Response(), "Failure sending request") 70 return 71 } 72 73 return 74} 75 76// CancelPreparer prepares the Cancel request. 77func (client VirtualMachineScaleSetRollingUpgradesClient) CancelPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string) (*http.Request, error) { 78 pathParameters := map[string]interface{}{ 79 "resourceGroupName": autorest.Encode("path", resourceGroupName), 80 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 81 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 82 } 83 84 const APIVersion = "2019-12-01" 85 queryParameters := map[string]interface{}{ 86 "api-version": APIVersion, 87 } 88 89 preparer := autorest.CreatePreparer( 90 autorest.AsPost(), 91 autorest.WithBaseURL(client.BaseURI), 92 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel", pathParameters), 93 autorest.WithQueryParameters(queryParameters)) 94 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 95} 96 97// CancelSender sends the Cancel request. The method will close the 98// http.Response Body if it receives an error. 99func (client VirtualMachineScaleSetRollingUpgradesClient) CancelSender(req *http.Request) (future VirtualMachineScaleSetRollingUpgradesCancelFuture, err error) { 100 var resp *http.Response 101 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 102 if err != nil { 103 return 104 } 105 future.Future, err = azure.NewFutureFromResponse(resp) 106 return 107} 108 109// CancelResponder handles the response to the Cancel request. The method always 110// closes the http.Response Body. 111func (client VirtualMachineScaleSetRollingUpgradesClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { 112 err = autorest.Respond( 113 resp, 114 client.ByInspecting(), 115 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 116 autorest.ByClosing()) 117 result.Response = resp 118 return 119} 120 121// GetLatest gets the status of the latest virtual machine scale set rolling upgrade. 122// Parameters: 123// resourceGroupName - the name of the resource group. 124// VMScaleSetName - the name of the VM scale set. 125func (client VirtualMachineScaleSetRollingUpgradesClient) GetLatest(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result RollingUpgradeStatusInfo, err error) { 126 if tracing.IsEnabled() { 127 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetRollingUpgradesClient.GetLatest") 128 defer func() { 129 sc := -1 130 if result.Response.Response != nil { 131 sc = result.Response.Response.StatusCode 132 } 133 tracing.EndSpan(ctx, sc, err) 134 }() 135 } 136 req, err := client.GetLatestPreparer(ctx, resourceGroupName, VMScaleSetName) 137 if err != nil { 138 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "GetLatest", nil, "Failure preparing request") 139 return 140 } 141 142 resp, err := client.GetLatestSender(req) 143 if err != nil { 144 result.Response = autorest.Response{Response: resp} 145 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "GetLatest", resp, "Failure sending request") 146 return 147 } 148 149 result, err = client.GetLatestResponder(resp) 150 if err != nil { 151 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "GetLatest", resp, "Failure responding to request") 152 } 153 154 return 155} 156 157// GetLatestPreparer prepares the GetLatest request. 158func (client VirtualMachineScaleSetRollingUpgradesClient) GetLatestPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string) (*http.Request, error) { 159 pathParameters := map[string]interface{}{ 160 "resourceGroupName": autorest.Encode("path", resourceGroupName), 161 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 162 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 163 } 164 165 const APIVersion = "2019-12-01" 166 queryParameters := map[string]interface{}{ 167 "api-version": APIVersion, 168 } 169 170 preparer := autorest.CreatePreparer( 171 autorest.AsGet(), 172 autorest.WithBaseURL(client.BaseURI), 173 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest", pathParameters), 174 autorest.WithQueryParameters(queryParameters)) 175 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 176} 177 178// GetLatestSender sends the GetLatest request. The method will close the 179// http.Response Body if it receives an error. 180func (client VirtualMachineScaleSetRollingUpgradesClient) GetLatestSender(req *http.Request) (*http.Response, error) { 181 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 182} 183 184// GetLatestResponder handles the response to the GetLatest request. The method always 185// closes the http.Response Body. 186func (client VirtualMachineScaleSetRollingUpgradesClient) GetLatestResponder(resp *http.Response) (result RollingUpgradeStatusInfo, err error) { 187 err = autorest.Respond( 188 resp, 189 client.ByInspecting(), 190 azure.WithErrorUnlessStatusCode(http.StatusOK), 191 autorest.ByUnmarshallingJSON(&result), 192 autorest.ByClosing()) 193 result.Response = autorest.Response{Response: resp} 194 return 195} 196 197// StartExtensionUpgrade starts a rolling upgrade to move all extensions for all virtual machine scale set instances to 198// the latest available extension version. Instances which are already running the latest extension versions are not 199// affected. 200// Parameters: 201// resourceGroupName - the name of the resource group. 202// VMScaleSetName - the name of the VM scale set. 203func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgrade(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture, err error) { 204 if tracing.IsEnabled() { 205 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetRollingUpgradesClient.StartExtensionUpgrade") 206 defer func() { 207 sc := -1 208 if result.Response() != nil { 209 sc = result.Response().StatusCode 210 } 211 tracing.EndSpan(ctx, sc, err) 212 }() 213 } 214 req, err := client.StartExtensionUpgradePreparer(ctx, resourceGroupName, VMScaleSetName) 215 if err != nil { 216 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "StartExtensionUpgrade", nil, "Failure preparing request") 217 return 218 } 219 220 result, err = client.StartExtensionUpgradeSender(req) 221 if err != nil { 222 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "StartExtensionUpgrade", result.Response(), "Failure sending request") 223 return 224 } 225 226 return 227} 228 229// StartExtensionUpgradePreparer prepares the StartExtensionUpgrade request. 230func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgradePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string) (*http.Request, error) { 231 pathParameters := map[string]interface{}{ 232 "resourceGroupName": autorest.Encode("path", resourceGroupName), 233 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 234 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 235 } 236 237 const APIVersion = "2019-12-01" 238 queryParameters := map[string]interface{}{ 239 "api-version": APIVersion, 240 } 241 242 preparer := autorest.CreatePreparer( 243 autorest.AsPost(), 244 autorest.WithBaseURL(client.BaseURI), 245 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", pathParameters), 246 autorest.WithQueryParameters(queryParameters)) 247 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 248} 249 250// StartExtensionUpgradeSender sends the StartExtensionUpgrade request. The method will close the 251// http.Response Body if it receives an error. 252func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgradeSender(req *http.Request) (future VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture, err error) { 253 var resp *http.Response 254 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 255 if err != nil { 256 return 257 } 258 future.Future, err = azure.NewFutureFromResponse(resp) 259 return 260} 261 262// StartExtensionUpgradeResponder handles the response to the StartExtensionUpgrade request. The method always 263// closes the http.Response Body. 264func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgradeResponder(resp *http.Response) (result autorest.Response, err error) { 265 err = autorest.Respond( 266 resp, 267 client.ByInspecting(), 268 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 269 autorest.ByClosing()) 270 result.Response = resp 271 return 272} 273 274// StartOSUpgrade starts a rolling upgrade to move all virtual machine scale set instances to the latest available 275// Platform Image OS version. Instances which are already running the latest available OS version are not affected. 276// Parameters: 277// resourceGroupName - the name of the resource group. 278// VMScaleSetName - the name of the VM scale set. 279func (client VirtualMachineScaleSetRollingUpgradesClient) StartOSUpgrade(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSetRollingUpgradesStartOSUpgradeFuture, err error) { 280 if tracing.IsEnabled() { 281 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetRollingUpgradesClient.StartOSUpgrade") 282 defer func() { 283 sc := -1 284 if result.Response() != nil { 285 sc = result.Response().StatusCode 286 } 287 tracing.EndSpan(ctx, sc, err) 288 }() 289 } 290 req, err := client.StartOSUpgradePreparer(ctx, resourceGroupName, VMScaleSetName) 291 if err != nil { 292 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "StartOSUpgrade", nil, "Failure preparing request") 293 return 294 } 295 296 result, err = client.StartOSUpgradeSender(req) 297 if err != nil { 298 err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "StartOSUpgrade", result.Response(), "Failure sending request") 299 return 300 } 301 302 return 303} 304 305// StartOSUpgradePreparer prepares the StartOSUpgrade request. 306func (client VirtualMachineScaleSetRollingUpgradesClient) StartOSUpgradePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string) (*http.Request, error) { 307 pathParameters := map[string]interface{}{ 308 "resourceGroupName": autorest.Encode("path", resourceGroupName), 309 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 310 "vmScaleSetName": autorest.Encode("path", VMScaleSetName), 311 } 312 313 const APIVersion = "2019-12-01" 314 queryParameters := map[string]interface{}{ 315 "api-version": APIVersion, 316 } 317 318 preparer := autorest.CreatePreparer( 319 autorest.AsPost(), 320 autorest.WithBaseURL(client.BaseURI), 321 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade", pathParameters), 322 autorest.WithQueryParameters(queryParameters)) 323 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 324} 325 326// StartOSUpgradeSender sends the StartOSUpgrade request. The method will close the 327// http.Response Body if it receives an error. 328func (client VirtualMachineScaleSetRollingUpgradesClient) StartOSUpgradeSender(req *http.Request) (future VirtualMachineScaleSetRollingUpgradesStartOSUpgradeFuture, err error) { 329 var resp *http.Response 330 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 331 if err != nil { 332 return 333 } 334 future.Future, err = azure.NewFutureFromResponse(resp) 335 return 336} 337 338// StartOSUpgradeResponder handles the response to the StartOSUpgrade request. The method always 339// closes the http.Response Body. 340func (client VirtualMachineScaleSetRollingUpgradesClient) StartOSUpgradeResponder(resp *http.Response) (result autorest.Response, err error) { 341 err = autorest.Respond( 342 resp, 343 client.ByInspecting(), 344 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 345 autorest.ByClosing()) 346 result.Response = resp 347 return 348} 349