| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.Compute.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Compute |
| | 18 | | { |
| | 19 | | internal partial class VirtualMachineScaleSetRollingUpgradesRestOperations |
| | 20 | | { |
| | 21 | | private string subscriptionId; |
| | 22 | | private Uri endpoint; |
| | 23 | | private ClientDiagnostics _clientDiagnostics; |
| | 24 | | private HttpPipeline _pipeline; |
| | 25 | |
|
| | 26 | | /// <summary> Initializes a new instance of VirtualMachineScaleSetRollingUpgradesRestOperations. </summary> |
| | 27 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 28 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 29 | | /// <param name="subscriptionId"> Subscription credentials which uniquely identify Microsoft Azure subscription. |
| | 30 | | /// <param name="endpoint"> server parameter. </param> |
| | 31 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 396 | 32 | | public VirtualMachineScaleSetRollingUpgradesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pip |
| | 33 | | { |
| 396 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 396 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 396 | 40 | | this.subscriptionId = subscriptionId; |
| 396 | 41 | | this.endpoint = endpoint; |
| 396 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 396 | 43 | | _pipeline = pipeline; |
| 396 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateCancelRequest(string resourceGroupName, string vmScaleSetName) |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Post; |
| 0 | 51 | | var uri = new RawRequestUriBuilder(); |
| 0 | 52 | | uri.Reset(endpoint); |
| 0 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 54 | | uri.AppendPath(subscriptionId, true); |
| 0 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 57 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 0 | 58 | | uri.AppendPath(vmScaleSetName, true); |
| 0 | 59 | | uri.AppendPath("/rollingUpgrades/cancel", false); |
| 0 | 60 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 61 | | request.Uri = uri; |
| 0 | 62 | | return message; |
| | 63 | | } |
| | 64 | |
|
| | 65 | | /// <summary> Cancels the current virtual machine scale set rolling upgrade. </summary> |
| | 66 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 67 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 68 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 69 | | public async Task<Response> CancelAsync(string resourceGroupName, string vmScaleSetName, CancellationToken cance |
| | 70 | | { |
| 0 | 71 | | if (resourceGroupName == null) |
| | 72 | | { |
| 0 | 73 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 74 | | } |
| 0 | 75 | | if (vmScaleSetName == null) |
| | 76 | | { |
| 0 | 77 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 78 | | } |
| | 79 | |
|
| 0 | 80 | | using var message = CreateCancelRequest(resourceGroupName, vmScaleSetName); |
| 0 | 81 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 82 | | switch (message.Response.Status) |
| | 83 | | { |
| | 84 | | case 200: |
| | 85 | | case 202: |
| 0 | 86 | | return message.Response; |
| | 87 | | default: |
| 0 | 88 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 89 | | } |
| 0 | 90 | | } |
| | 91 | |
|
| | 92 | | /// <summary> Cancels the current virtual machine scale set rolling upgrade. </summary> |
| | 93 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 94 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 95 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 96 | | public Response Cancel(string resourceGroupName, string vmScaleSetName, CancellationToken cancellationToken = de |
| | 97 | | { |
| 0 | 98 | | if (resourceGroupName == null) |
| | 99 | | { |
| 0 | 100 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 101 | | } |
| 0 | 102 | | if (vmScaleSetName == null) |
| | 103 | | { |
| 0 | 104 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 105 | | } |
| | 106 | |
|
| 0 | 107 | | using var message = CreateCancelRequest(resourceGroupName, vmScaleSetName); |
| 0 | 108 | | _pipeline.Send(message, cancellationToken); |
| 0 | 109 | | switch (message.Response.Status) |
| | 110 | | { |
| | 111 | | case 200: |
| | 112 | | case 202: |
| 0 | 113 | | return message.Response; |
| | 114 | | default: |
| 0 | 115 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 116 | | } |
| 0 | 117 | | } |
| | 118 | |
|
| | 119 | | internal HttpMessage CreateStartOSUpgradeRequest(string resourceGroupName, string vmScaleSetName) |
| | 120 | | { |
| 0 | 121 | | var message = _pipeline.CreateMessage(); |
| 0 | 122 | | var request = message.Request; |
| 0 | 123 | | request.Method = RequestMethod.Post; |
| 0 | 124 | | var uri = new RawRequestUriBuilder(); |
| 0 | 125 | | uri.Reset(endpoint); |
| 0 | 126 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 127 | | uri.AppendPath(subscriptionId, true); |
| 0 | 128 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 129 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 130 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 0 | 131 | | uri.AppendPath(vmScaleSetName, true); |
| 0 | 132 | | uri.AppendPath("/osRollingUpgrade", false); |
| 0 | 133 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 134 | | request.Uri = uri; |
| 0 | 135 | | return message; |
| | 136 | | } |
| | 137 | |
|
| | 138 | | /// <summary> Starts a rolling upgrade to move all virtual machine scale set instances to the latest available P |
| | 139 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 140 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 141 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 142 | | public async Task<Response> StartOSUpgradeAsync(string resourceGroupName, string vmScaleSetName, CancellationTok |
| | 143 | | { |
| 0 | 144 | | if (resourceGroupName == null) |
| | 145 | | { |
| 0 | 146 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 147 | | } |
| 0 | 148 | | if (vmScaleSetName == null) |
| | 149 | | { |
| 0 | 150 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 151 | | } |
| | 152 | |
|
| 0 | 153 | | using var message = CreateStartOSUpgradeRequest(resourceGroupName, vmScaleSetName); |
| 0 | 154 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 155 | | switch (message.Response.Status) |
| | 156 | | { |
| | 157 | | case 200: |
| | 158 | | case 202: |
| 0 | 159 | | return message.Response; |
| | 160 | | default: |
| 0 | 161 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 162 | | } |
| 0 | 163 | | } |
| | 164 | |
|
| | 165 | | /// <summary> Starts a rolling upgrade to move all virtual machine scale set instances to the latest available P |
| | 166 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 167 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 168 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 169 | | public Response StartOSUpgrade(string resourceGroupName, string vmScaleSetName, CancellationToken cancellationTo |
| | 170 | | { |
| 0 | 171 | | if (resourceGroupName == null) |
| | 172 | | { |
| 0 | 173 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 174 | | } |
| 0 | 175 | | if (vmScaleSetName == null) |
| | 176 | | { |
| 0 | 177 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 178 | | } |
| | 179 | |
|
| 0 | 180 | | using var message = CreateStartOSUpgradeRequest(resourceGroupName, vmScaleSetName); |
| 0 | 181 | | _pipeline.Send(message, cancellationToken); |
| 0 | 182 | | switch (message.Response.Status) |
| | 183 | | { |
| | 184 | | case 200: |
| | 185 | | case 202: |
| 0 | 186 | | return message.Response; |
| | 187 | | default: |
| 0 | 188 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 189 | | } |
| 0 | 190 | | } |
| | 191 | |
|
| | 192 | | internal HttpMessage CreateStartExtensionUpgradeRequest(string resourceGroupName, string vmScaleSetName) |
| | 193 | | { |
| 0 | 194 | | var message = _pipeline.CreateMessage(); |
| 0 | 195 | | var request = message.Request; |
| 0 | 196 | | request.Method = RequestMethod.Post; |
| 0 | 197 | | var uri = new RawRequestUriBuilder(); |
| 0 | 198 | | uri.Reset(endpoint); |
| 0 | 199 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 200 | | uri.AppendPath(subscriptionId, true); |
| 0 | 201 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 202 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 203 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 0 | 204 | | uri.AppendPath(vmScaleSetName, true); |
| 0 | 205 | | uri.AppendPath("/extensionRollingUpgrade", false); |
| 0 | 206 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 207 | | request.Uri = uri; |
| 0 | 208 | | return message; |
| | 209 | | } |
| | 210 | |
|
| | 211 | | /// <summary> Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to the |
| | 212 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 213 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 214 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 215 | | public async Task<Response> StartExtensionUpgradeAsync(string resourceGroupName, string vmScaleSetName, Cancella |
| | 216 | | { |
| 0 | 217 | | if (resourceGroupName == null) |
| | 218 | | { |
| 0 | 219 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 220 | | } |
| 0 | 221 | | if (vmScaleSetName == null) |
| | 222 | | { |
| 0 | 223 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 224 | | } |
| | 225 | |
|
| 0 | 226 | | using var message = CreateStartExtensionUpgradeRequest(resourceGroupName, vmScaleSetName); |
| 0 | 227 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 228 | | switch (message.Response.Status) |
| | 229 | | { |
| | 230 | | case 200: |
| | 231 | | case 202: |
| 0 | 232 | | return message.Response; |
| | 233 | | default: |
| 0 | 234 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 235 | | } |
| 0 | 236 | | } |
| | 237 | |
|
| | 238 | | /// <summary> Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to the |
| | 239 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 240 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 241 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 242 | | public Response StartExtensionUpgrade(string resourceGroupName, string vmScaleSetName, CancellationToken cancell |
| | 243 | | { |
| 0 | 244 | | if (resourceGroupName == null) |
| | 245 | | { |
| 0 | 246 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 247 | | } |
| 0 | 248 | | if (vmScaleSetName == null) |
| | 249 | | { |
| 0 | 250 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 251 | | } |
| | 252 | |
|
| 0 | 253 | | using var message = CreateStartExtensionUpgradeRequest(resourceGroupName, vmScaleSetName); |
| 0 | 254 | | _pipeline.Send(message, cancellationToken); |
| 0 | 255 | | switch (message.Response.Status) |
| | 256 | | { |
| | 257 | | case 200: |
| | 258 | | case 202: |
| 0 | 259 | | return message.Response; |
| | 260 | | default: |
| 0 | 261 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 262 | | } |
| 0 | 263 | | } |
| | 264 | |
|
| | 265 | | internal HttpMessage CreateGetLatestRequest(string resourceGroupName, string vmScaleSetName) |
| | 266 | | { |
| 0 | 267 | | var message = _pipeline.CreateMessage(); |
| 0 | 268 | | var request = message.Request; |
| 0 | 269 | | request.Method = RequestMethod.Get; |
| 0 | 270 | | var uri = new RawRequestUriBuilder(); |
| 0 | 271 | | uri.Reset(endpoint); |
| 0 | 272 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 273 | | uri.AppendPath(subscriptionId, true); |
| 0 | 274 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 275 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 276 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 0 | 277 | | uri.AppendPath(vmScaleSetName, true); |
| 0 | 278 | | uri.AppendPath("/rollingUpgrades/latest", false); |
| 0 | 279 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 280 | | request.Uri = uri; |
| 0 | 281 | | return message; |
| | 282 | | } |
| | 283 | |
|
| | 284 | | /// <summary> Gets the status of the latest virtual machine scale set rolling upgrade. </summary> |
| | 285 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 286 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 287 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 288 | | public async Task<Response<RollingUpgradeStatusInfo>> GetLatestAsync(string resourceGroupName, string vmScaleSet |
| | 289 | | { |
| 0 | 290 | | if (resourceGroupName == null) |
| | 291 | | { |
| 0 | 292 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 293 | | } |
| 0 | 294 | | if (vmScaleSetName == null) |
| | 295 | | { |
| 0 | 296 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 297 | | } |
| | 298 | |
|
| 0 | 299 | | using var message = CreateGetLatestRequest(resourceGroupName, vmScaleSetName); |
| 0 | 300 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 301 | | switch (message.Response.Status) |
| | 302 | | { |
| | 303 | | case 200: |
| | 304 | | { |
| 0 | 305 | | RollingUpgradeStatusInfo value = default; |
| 0 | 306 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 307 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 308 | | { |
| 0 | 309 | | value = null; |
| | 310 | | } |
| | 311 | | else |
| | 312 | | { |
| 0 | 313 | | value = RollingUpgradeStatusInfo.DeserializeRollingUpgradeStatusInfo(document.RootElement); |
| | 314 | | } |
| 0 | 315 | | return Response.FromValue(value, message.Response); |
| | 316 | | } |
| | 317 | | default: |
| 0 | 318 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 319 | | } |
| 0 | 320 | | } |
| | 321 | |
|
| | 322 | | /// <summary> Gets the status of the latest virtual machine scale set rolling upgrade. </summary> |
| | 323 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 324 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 325 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 326 | | public Response<RollingUpgradeStatusInfo> GetLatest(string resourceGroupName, string vmScaleSetName, Cancellatio |
| | 327 | | { |
| 0 | 328 | | if (resourceGroupName == null) |
| | 329 | | { |
| 0 | 330 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 331 | | } |
| 0 | 332 | | if (vmScaleSetName == null) |
| | 333 | | { |
| 0 | 334 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 335 | | } |
| | 336 | |
|
| 0 | 337 | | using var message = CreateGetLatestRequest(resourceGroupName, vmScaleSetName); |
| 0 | 338 | | _pipeline.Send(message, cancellationToken); |
| 0 | 339 | | switch (message.Response.Status) |
| | 340 | | { |
| | 341 | | case 200: |
| | 342 | | { |
| 0 | 343 | | RollingUpgradeStatusInfo value = default; |
| 0 | 344 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 345 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 346 | | { |
| 0 | 347 | | value = null; |
| | 348 | | } |
| | 349 | | else |
| | 350 | | { |
| 0 | 351 | | value = RollingUpgradeStatusInfo.DeserializeRollingUpgradeStatusInfo(document.RootElement); |
| | 352 | | } |
| 0 | 353 | | return Response.FromValue(value, message.Response); |
| | 354 | | } |
| | 355 | | default: |
| 0 | 356 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 357 | | } |
| 0 | 358 | | } |
| | 359 | | } |
| | 360 | | } |