| | 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.Collections.Generic; |
| | 10 | | using System.Text.Json; |
| | 11 | | using System.Threading; |
| | 12 | | using System.Threading.Tasks; |
| | 13 | | using Azure; |
| | 14 | | using Azure.Core; |
| | 15 | | using Azure.Core.Pipeline; |
| | 16 | | using Azure.ResourceManager.Compute.Models; |
| | 17 | |
|
| | 18 | | namespace Azure.ResourceManager.Compute |
| | 19 | | { |
| | 20 | | internal partial class VirtualMachineImagesRestOperations |
| | 21 | | { |
| | 22 | | private string subscriptionId; |
| | 23 | | private Uri endpoint; |
| | 24 | | private ClientDiagnostics _clientDiagnostics; |
| | 25 | | private HttpPipeline _pipeline; |
| | 26 | |
|
| | 27 | | /// <summary> Initializes a new instance of VirtualMachineImagesRestOperations. </summary> |
| | 28 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 29 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 30 | | /// <param name="subscriptionId"> Subscription credentials which uniquely identify Microsoft Azure subscription. |
| | 31 | | /// <param name="endpoint"> server parameter. </param> |
| | 32 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 396 | 33 | | public VirtualMachineImagesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string sub |
| | 34 | | { |
| 396 | 35 | | if (subscriptionId == null) |
| | 36 | | { |
| 0 | 37 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 38 | | } |
| 396 | 39 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 40 | |
|
| 396 | 41 | | this.subscriptionId = subscriptionId; |
| 396 | 42 | | this.endpoint = endpoint; |
| 396 | 43 | | _clientDiagnostics = clientDiagnostics; |
| 396 | 44 | | _pipeline = pipeline; |
| 396 | 45 | | } |
| | 46 | |
|
| | 47 | | internal HttpMessage CreateGetRequest(string location, string publisherName, string offer, string skus, string v |
| | 48 | | { |
| 32 | 49 | | var message = _pipeline.CreateMessage(); |
| 32 | 50 | | var request = message.Request; |
| 32 | 51 | | request.Method = RequestMethod.Get; |
| 32 | 52 | | var uri = new RawRequestUriBuilder(); |
| 32 | 53 | | uri.Reset(endpoint); |
| 32 | 54 | | uri.AppendPath("/subscriptions/", false); |
| 32 | 55 | | uri.AppendPath(subscriptionId, true); |
| 32 | 56 | | uri.AppendPath("/providers/Microsoft.Compute/locations/", false); |
| 32 | 57 | | uri.AppendPath(location, true); |
| 32 | 58 | | uri.AppendPath("/publishers/", false); |
| 32 | 59 | | uri.AppendPath(publisherName, true); |
| 32 | 60 | | uri.AppendPath("/artifacttypes/vmimage/offers/", false); |
| 32 | 61 | | uri.AppendPath(offer, true); |
| 32 | 62 | | uri.AppendPath("/skus/", false); |
| 32 | 63 | | uri.AppendPath(skus, true); |
| 32 | 64 | | uri.AppendPath("/versions/", false); |
| 32 | 65 | | uri.AppendPath(version, true); |
| 32 | 66 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 32 | 67 | | request.Uri = uri; |
| 32 | 68 | | return message; |
| | 69 | | } |
| | 70 | |
|
| | 71 | | /// <summary> Gets a virtual machine image. </summary> |
| | 72 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 73 | | /// <param name="publisherName"> A valid image publisher. </param> |
| | 74 | | /// <param name="offer"> A valid image publisher offer. </param> |
| | 75 | | /// <param name="skus"> A valid image SKU. </param> |
| | 76 | | /// <param name="version"> A valid image SKU version. </param> |
| | 77 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 78 | | public async Task<Response<VirtualMachineImage>> GetAsync(string location, string publisherName, string offer, s |
| | 79 | | { |
| 16 | 80 | | if (location == null) |
| | 81 | | { |
| 0 | 82 | | throw new ArgumentNullException(nameof(location)); |
| | 83 | | } |
| 16 | 84 | | if (publisherName == null) |
| | 85 | | { |
| 0 | 86 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 87 | | } |
| 16 | 88 | | if (offer == null) |
| | 89 | | { |
| 0 | 90 | | throw new ArgumentNullException(nameof(offer)); |
| | 91 | | } |
| 16 | 92 | | if (skus == null) |
| | 93 | | { |
| 0 | 94 | | throw new ArgumentNullException(nameof(skus)); |
| | 95 | | } |
| 16 | 96 | | if (version == null) |
| | 97 | | { |
| 0 | 98 | | throw new ArgumentNullException(nameof(version)); |
| | 99 | | } |
| | 100 | |
|
| 16 | 101 | | using var message = CreateGetRequest(location, publisherName, offer, skus, version); |
| 16 | 102 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 16 | 103 | | switch (message.Response.Status) |
| | 104 | | { |
| | 105 | | case 200: |
| | 106 | | { |
| 16 | 107 | | VirtualMachineImage value = default; |
| 16 | 108 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 16 | 109 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 110 | | { |
| 0 | 111 | | value = null; |
| | 112 | | } |
| | 113 | | else |
| | 114 | | { |
| 16 | 115 | | value = VirtualMachineImage.DeserializeVirtualMachineImage(document.RootElement); |
| | 116 | | } |
| 16 | 117 | | return Response.FromValue(value, message.Response); |
| | 118 | | } |
| | 119 | | default: |
| 0 | 120 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 121 | | } |
| 16 | 122 | | } |
| | 123 | |
|
| | 124 | | /// <summary> Gets a virtual machine image. </summary> |
| | 125 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 126 | | /// <param name="publisherName"> A valid image publisher. </param> |
| | 127 | | /// <param name="offer"> A valid image publisher offer. </param> |
| | 128 | | /// <param name="skus"> A valid image SKU. </param> |
| | 129 | | /// <param name="version"> A valid image SKU version. </param> |
| | 130 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 131 | | public Response<VirtualMachineImage> Get(string location, string publisherName, string offer, string skus, strin |
| | 132 | | { |
| 16 | 133 | | if (location == null) |
| | 134 | | { |
| 0 | 135 | | throw new ArgumentNullException(nameof(location)); |
| | 136 | | } |
| 16 | 137 | | if (publisherName == null) |
| | 138 | | { |
| 0 | 139 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 140 | | } |
| 16 | 141 | | if (offer == null) |
| | 142 | | { |
| 0 | 143 | | throw new ArgumentNullException(nameof(offer)); |
| | 144 | | } |
| 16 | 145 | | if (skus == null) |
| | 146 | | { |
| 0 | 147 | | throw new ArgumentNullException(nameof(skus)); |
| | 148 | | } |
| 16 | 149 | | if (version == null) |
| | 150 | | { |
| 0 | 151 | | throw new ArgumentNullException(nameof(version)); |
| | 152 | | } |
| | 153 | |
|
| 16 | 154 | | using var message = CreateGetRequest(location, publisherName, offer, skus, version); |
| 16 | 155 | | _pipeline.Send(message, cancellationToken); |
| 16 | 156 | | switch (message.Response.Status) |
| | 157 | | { |
| | 158 | | case 200: |
| | 159 | | { |
| 16 | 160 | | VirtualMachineImage value = default; |
| 16 | 161 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 16 | 162 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 163 | | { |
| 0 | 164 | | value = null; |
| | 165 | | } |
| | 166 | | else |
| | 167 | | { |
| 16 | 168 | | value = VirtualMachineImage.DeserializeVirtualMachineImage(document.RootElement); |
| | 169 | | } |
| 16 | 170 | | return Response.FromValue(value, message.Response); |
| | 171 | | } |
| | 172 | | default: |
| 0 | 173 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 174 | | } |
| 16 | 175 | | } |
| | 176 | |
|
| | 177 | | internal HttpMessage CreateListRequest(string location, string publisherName, string offer, string skus, string |
| | 178 | | { |
| 320 | 179 | | var message = _pipeline.CreateMessage(); |
| 320 | 180 | | var request = message.Request; |
| 320 | 181 | | request.Method = RequestMethod.Get; |
| 320 | 182 | | var uri = new RawRequestUriBuilder(); |
| 320 | 183 | | uri.Reset(endpoint); |
| 320 | 184 | | uri.AppendPath("/subscriptions/", false); |
| 320 | 185 | | uri.AppendPath(subscriptionId, true); |
| 320 | 186 | | uri.AppendPath("/providers/Microsoft.Compute/locations/", false); |
| 320 | 187 | | uri.AppendPath(location, true); |
| 320 | 188 | | uri.AppendPath("/publishers/", false); |
| 320 | 189 | | uri.AppendPath(publisherName, true); |
| 320 | 190 | | uri.AppendPath("/artifacttypes/vmimage/offers/", false); |
| 320 | 191 | | uri.AppendPath(offer, true); |
| 320 | 192 | | uri.AppendPath("/skus/", false); |
| 320 | 193 | | uri.AppendPath(skus, true); |
| 320 | 194 | | uri.AppendPath("/versions", false); |
| 320 | 195 | | if (expand != null) |
| | 196 | | { |
| 0 | 197 | | uri.AppendQuery("$expand", expand, true); |
| | 198 | | } |
| 320 | 199 | | if (top != null) |
| | 200 | | { |
| 300 | 201 | | uri.AppendQuery("$top", top.Value, true); |
| | 202 | | } |
| 320 | 203 | | if (orderby != null) |
| | 204 | | { |
| 16 | 205 | | uri.AppendQuery("$orderby", orderby, true); |
| | 206 | | } |
| 320 | 207 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 320 | 208 | | request.Uri = uri; |
| 320 | 209 | | return message; |
| | 210 | | } |
| | 211 | |
|
| | 212 | | /// <summary> Gets a list of all virtual machine image versions for the specified location, publisher, offer, an |
| | 213 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 214 | | /// <param name="publisherName"> A valid image publisher. </param> |
| | 215 | | /// <param name="offer"> A valid image publisher offer. </param> |
| | 216 | | /// <param name="skus"> A valid image SKU. </param> |
| | 217 | | /// <param name="expand"> The expand expression to apply on the operation. </param> |
| | 218 | | /// <param name="top"> The Integer to use. </param> |
| | 219 | | /// <param name="orderby"> The String to use. </param> |
| | 220 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 221 | | public async Task<Response<IReadOnlyList<VirtualMachineImageResource>>> ListAsync(string location, string publis |
| | 222 | | { |
| 160 | 223 | | if (location == null) |
| | 224 | | { |
| 0 | 225 | | throw new ArgumentNullException(nameof(location)); |
| | 226 | | } |
| 160 | 227 | | if (publisherName == null) |
| | 228 | | { |
| 0 | 229 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 230 | | } |
| 160 | 231 | | if (offer == null) |
| | 232 | | { |
| 0 | 233 | | throw new ArgumentNullException(nameof(offer)); |
| | 234 | | } |
| 160 | 235 | | if (skus == null) |
| | 236 | | { |
| 0 | 237 | | throw new ArgumentNullException(nameof(skus)); |
| | 238 | | } |
| | 239 | |
|
| 160 | 240 | | using var message = CreateListRequest(location, publisherName, offer, skus, expand, top, orderby); |
| 160 | 241 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 160 | 242 | | switch (message.Response.Status) |
| | 243 | | { |
| | 244 | | case 200: |
| | 245 | | { |
| 160 | 246 | | IReadOnlyList<VirtualMachineImageResource> value = default; |
| 160 | 247 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 160 | 248 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 249 | | { |
| 0 | 250 | | value = null; |
| | 251 | | } |
| | 252 | | else |
| | 253 | | { |
| 160 | 254 | | List<VirtualMachineImageResource> array = new List<VirtualMachineImageResource>(); |
| 1028 | 255 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 256 | | { |
| 354 | 257 | | if (item.ValueKind == JsonValueKind.Null) |
| | 258 | | { |
| 0 | 259 | | array.Add(null); |
| | 260 | | } |
| | 261 | | else |
| | 262 | | { |
| 354 | 263 | | array.Add(VirtualMachineImageResource.DeserializeVirtualMachineImageResource(item)); |
| | 264 | | } |
| | 265 | | } |
| 160 | 266 | | value = array; |
| | 267 | | } |
| 160 | 268 | | return Response.FromValue(value, message.Response); |
| | 269 | | } |
| | 270 | | default: |
| 0 | 271 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 272 | | } |
| 160 | 273 | | } |
| | 274 | |
|
| | 275 | | /// <summary> Gets a list of all virtual machine image versions for the specified location, publisher, offer, an |
| | 276 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 277 | | /// <param name="publisherName"> A valid image publisher. </param> |
| | 278 | | /// <param name="offer"> A valid image publisher offer. </param> |
| | 279 | | /// <param name="skus"> A valid image SKU. </param> |
| | 280 | | /// <param name="expand"> The expand expression to apply on the operation. </param> |
| | 281 | | /// <param name="top"> The Integer to use. </param> |
| | 282 | | /// <param name="orderby"> The String to use. </param> |
| | 283 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 284 | | public Response<IReadOnlyList<VirtualMachineImageResource>> List(string location, string publisherName, string o |
| | 285 | | { |
| 160 | 286 | | if (location == null) |
| | 287 | | { |
| 0 | 288 | | throw new ArgumentNullException(nameof(location)); |
| | 289 | | } |
| 160 | 290 | | if (publisherName == null) |
| | 291 | | { |
| 0 | 292 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 293 | | } |
| 160 | 294 | | if (offer == null) |
| | 295 | | { |
| 0 | 296 | | throw new ArgumentNullException(nameof(offer)); |
| | 297 | | } |
| 160 | 298 | | if (skus == null) |
| | 299 | | { |
| 0 | 300 | | throw new ArgumentNullException(nameof(skus)); |
| | 301 | | } |
| | 302 | |
|
| 160 | 303 | | using var message = CreateListRequest(location, publisherName, offer, skus, expand, top, orderby); |
| 160 | 304 | | _pipeline.Send(message, cancellationToken); |
| 160 | 305 | | switch (message.Response.Status) |
| | 306 | | { |
| | 307 | | case 200: |
| | 308 | | { |
| 160 | 309 | | IReadOnlyList<VirtualMachineImageResource> value = default; |
| 160 | 310 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 160 | 311 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 312 | | { |
| 0 | 313 | | value = null; |
| | 314 | | } |
| | 315 | | else |
| | 316 | | { |
| 160 | 317 | | List<VirtualMachineImageResource> array = new List<VirtualMachineImageResource>(); |
| 1028 | 318 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 319 | | { |
| 354 | 320 | | if (item.ValueKind == JsonValueKind.Null) |
| | 321 | | { |
| 0 | 322 | | array.Add(null); |
| | 323 | | } |
| | 324 | | else |
| | 325 | | { |
| 354 | 326 | | array.Add(VirtualMachineImageResource.DeserializeVirtualMachineImageResource(item)); |
| | 327 | | } |
| | 328 | | } |
| 160 | 329 | | value = array; |
| | 330 | | } |
| 160 | 331 | | return Response.FromValue(value, message.Response); |
| | 332 | | } |
| | 333 | | default: |
| 0 | 334 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 335 | | } |
| 160 | 336 | | } |
| | 337 | |
|
| | 338 | | internal HttpMessage CreateListOffersRequest(string location, string publisherName) |
| | 339 | | { |
| 4 | 340 | | var message = _pipeline.CreateMessage(); |
| 4 | 341 | | var request = message.Request; |
| 4 | 342 | | request.Method = RequestMethod.Get; |
| 4 | 343 | | var uri = new RawRequestUriBuilder(); |
| 4 | 344 | | uri.Reset(endpoint); |
| 4 | 345 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 346 | | uri.AppendPath(subscriptionId, true); |
| 4 | 347 | | uri.AppendPath("/providers/Microsoft.Compute/locations/", false); |
| 4 | 348 | | uri.AppendPath(location, true); |
| 4 | 349 | | uri.AppendPath("/publishers/", false); |
| 4 | 350 | | uri.AppendPath(publisherName, true); |
| 4 | 351 | | uri.AppendPath("/artifacttypes/vmimage/offers", false); |
| 4 | 352 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 4 | 353 | | request.Uri = uri; |
| 4 | 354 | | return message; |
| | 355 | | } |
| | 356 | |
|
| | 357 | | /// <summary> Gets a list of virtual machine image offers for the specified location and publisher. </summary> |
| | 358 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 359 | | /// <param name="publisherName"> A valid image publisher. </param> |
| | 360 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 361 | | public async Task<Response<IReadOnlyList<VirtualMachineImageResource>>> ListOffersAsync(string location, string |
| | 362 | | { |
| 2 | 363 | | if (location == null) |
| | 364 | | { |
| 0 | 365 | | throw new ArgumentNullException(nameof(location)); |
| | 366 | | } |
| 2 | 367 | | if (publisherName == null) |
| | 368 | | { |
| 0 | 369 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 370 | | } |
| | 371 | |
|
| 2 | 372 | | using var message = CreateListOffersRequest(location, publisherName); |
| 2 | 373 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 374 | | switch (message.Response.Status) |
| | 375 | | { |
| | 376 | | case 200: |
| | 377 | | { |
| 2 | 378 | | IReadOnlyList<VirtualMachineImageResource> value = default; |
| 2 | 379 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 380 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 381 | | { |
| 0 | 382 | | value = null; |
| | 383 | | } |
| | 384 | | else |
| | 385 | | { |
| 2 | 386 | | List<VirtualMachineImageResource> array = new List<VirtualMachineImageResource>(); |
| 80 | 387 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 388 | | { |
| 38 | 389 | | if (item.ValueKind == JsonValueKind.Null) |
| | 390 | | { |
| 0 | 391 | | array.Add(null); |
| | 392 | | } |
| | 393 | | else |
| | 394 | | { |
| 38 | 395 | | array.Add(VirtualMachineImageResource.DeserializeVirtualMachineImageResource(item)); |
| | 396 | | } |
| | 397 | | } |
| 2 | 398 | | value = array; |
| | 399 | | } |
| 2 | 400 | | return Response.FromValue(value, message.Response); |
| | 401 | | } |
| | 402 | | default: |
| 0 | 403 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 404 | | } |
| 2 | 405 | | } |
| | 406 | |
|
| | 407 | | /// <summary> Gets a list of virtual machine image offers for the specified location and publisher. </summary> |
| | 408 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 409 | | /// <param name="publisherName"> A valid image publisher. </param> |
| | 410 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 411 | | public Response<IReadOnlyList<VirtualMachineImageResource>> ListOffers(string location, string publisherName, Ca |
| | 412 | | { |
| 2 | 413 | | if (location == null) |
| | 414 | | { |
| 0 | 415 | | throw new ArgumentNullException(nameof(location)); |
| | 416 | | } |
| 2 | 417 | | if (publisherName == null) |
| | 418 | | { |
| 0 | 419 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 420 | | } |
| | 421 | |
|
| 2 | 422 | | using var message = CreateListOffersRequest(location, publisherName); |
| 2 | 423 | | _pipeline.Send(message, cancellationToken); |
| 2 | 424 | | switch (message.Response.Status) |
| | 425 | | { |
| | 426 | | case 200: |
| | 427 | | { |
| 2 | 428 | | IReadOnlyList<VirtualMachineImageResource> value = default; |
| 2 | 429 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 430 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 431 | | { |
| 0 | 432 | | value = null; |
| | 433 | | } |
| | 434 | | else |
| | 435 | | { |
| 2 | 436 | | List<VirtualMachineImageResource> array = new List<VirtualMachineImageResource>(); |
| 80 | 437 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 438 | | { |
| 38 | 439 | | if (item.ValueKind == JsonValueKind.Null) |
| | 440 | | { |
| 0 | 441 | | array.Add(null); |
| | 442 | | } |
| | 443 | | else |
| | 444 | | { |
| 38 | 445 | | array.Add(VirtualMachineImageResource.DeserializeVirtualMachineImageResource(item)); |
| | 446 | | } |
| | 447 | | } |
| 2 | 448 | | value = array; |
| | 449 | | } |
| 2 | 450 | | return Response.FromValue(value, message.Response); |
| | 451 | | } |
| | 452 | | default: |
| 0 | 453 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 454 | | } |
| 2 | 455 | | } |
| | 456 | |
|
| | 457 | | internal HttpMessage CreateListPublishersRequest(string location) |
| | 458 | | { |
| 4 | 459 | | var message = _pipeline.CreateMessage(); |
| 4 | 460 | | var request = message.Request; |
| 4 | 461 | | request.Method = RequestMethod.Get; |
| 4 | 462 | | var uri = new RawRequestUriBuilder(); |
| 4 | 463 | | uri.Reset(endpoint); |
| 4 | 464 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 465 | | uri.AppendPath(subscriptionId, true); |
| 4 | 466 | | uri.AppendPath("/providers/Microsoft.Compute/locations/", false); |
| 4 | 467 | | uri.AppendPath(location, true); |
| 4 | 468 | | uri.AppendPath("/publishers", false); |
| 4 | 469 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 4 | 470 | | request.Uri = uri; |
| 4 | 471 | | return message; |
| | 472 | | } |
| | 473 | |
|
| | 474 | | /// <summary> Gets a list of virtual machine image publishers for the specified Azure location. </summary> |
| | 475 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 476 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 477 | | public async Task<Response<IReadOnlyList<VirtualMachineImageResource>>> ListPublishersAsync(string location, Can |
| | 478 | | { |
| 2 | 479 | | if (location == null) |
| | 480 | | { |
| 0 | 481 | | throw new ArgumentNullException(nameof(location)); |
| | 482 | | } |
| | 483 | |
|
| 2 | 484 | | using var message = CreateListPublishersRequest(location); |
| 2 | 485 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 486 | | switch (message.Response.Status) |
| | 487 | | { |
| | 488 | | case 200: |
| | 489 | | { |
| 2 | 490 | | IReadOnlyList<VirtualMachineImageResource> value = default; |
| 2 | 491 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 492 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 493 | | { |
| 0 | 494 | | value = null; |
| | 495 | | } |
| | 496 | | else |
| | 497 | | { |
| 2 | 498 | | List<VirtualMachineImageResource> array = new List<VirtualMachineImageResource>(); |
| 5216 | 499 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 500 | | { |
| 2606 | 501 | | if (item.ValueKind == JsonValueKind.Null) |
| | 502 | | { |
| 0 | 503 | | array.Add(null); |
| | 504 | | } |
| | 505 | | else |
| | 506 | | { |
| 2606 | 507 | | array.Add(VirtualMachineImageResource.DeserializeVirtualMachineImageResource(item)); |
| | 508 | | } |
| | 509 | | } |
| 2 | 510 | | value = array; |
| | 511 | | } |
| 2 | 512 | | return Response.FromValue(value, message.Response); |
| | 513 | | } |
| | 514 | | default: |
| 0 | 515 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 516 | | } |
| 2 | 517 | | } |
| | 518 | |
|
| | 519 | | /// <summary> Gets a list of virtual machine image publishers for the specified Azure location. </summary> |
| | 520 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 521 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 522 | | public Response<IReadOnlyList<VirtualMachineImageResource>> ListPublishers(string location, CancellationToken ca |
| | 523 | | { |
| 2 | 524 | | if (location == null) |
| | 525 | | { |
| 0 | 526 | | throw new ArgumentNullException(nameof(location)); |
| | 527 | | } |
| | 528 | |
|
| 2 | 529 | | using var message = CreateListPublishersRequest(location); |
| 2 | 530 | | _pipeline.Send(message, cancellationToken); |
| 2 | 531 | | switch (message.Response.Status) |
| | 532 | | { |
| | 533 | | case 200: |
| | 534 | | { |
| 2 | 535 | | IReadOnlyList<VirtualMachineImageResource> value = default; |
| 2 | 536 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 537 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 538 | | { |
| 0 | 539 | | value = null; |
| | 540 | | } |
| | 541 | | else |
| | 542 | | { |
| 2 | 543 | | List<VirtualMachineImageResource> array = new List<VirtualMachineImageResource>(); |
| 5216 | 544 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 545 | | { |
| 2606 | 546 | | if (item.ValueKind == JsonValueKind.Null) |
| | 547 | | { |
| 0 | 548 | | array.Add(null); |
| | 549 | | } |
| | 550 | | else |
| | 551 | | { |
| 2606 | 552 | | array.Add(VirtualMachineImageResource.DeserializeVirtualMachineImageResource(item)); |
| | 553 | | } |
| | 554 | | } |
| 2 | 555 | | value = array; |
| | 556 | | } |
| 2 | 557 | | return Response.FromValue(value, message.Response); |
| | 558 | | } |
| | 559 | | default: |
| 0 | 560 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 561 | | } |
| 2 | 562 | | } |
| | 563 | |
|
| | 564 | | internal HttpMessage CreateListSkusRequest(string location, string publisherName, string offer) |
| | 565 | | { |
| 8 | 566 | | var message = _pipeline.CreateMessage(); |
| 8 | 567 | | var request = message.Request; |
| 8 | 568 | | request.Method = RequestMethod.Get; |
| 8 | 569 | | var uri = new RawRequestUriBuilder(); |
| 8 | 570 | | uri.Reset(endpoint); |
| 8 | 571 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 572 | | uri.AppendPath(subscriptionId, true); |
| 8 | 573 | | uri.AppendPath("/providers/Microsoft.Compute/locations/", false); |
| 8 | 574 | | uri.AppendPath(location, true); |
| 8 | 575 | | uri.AppendPath("/publishers/", false); |
| 8 | 576 | | uri.AppendPath(publisherName, true); |
| 8 | 577 | | uri.AppendPath("/artifacttypes/vmimage/offers/", false); |
| 8 | 578 | | uri.AppendPath(offer, true); |
| 8 | 579 | | uri.AppendPath("/skus", false); |
| 8 | 580 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 8 | 581 | | request.Uri = uri; |
| 8 | 582 | | return message; |
| | 583 | | } |
| | 584 | |
|
| | 585 | | /// <summary> Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. </summ |
| | 586 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 587 | | /// <param name="publisherName"> A valid image publisher. </param> |
| | 588 | | /// <param name="offer"> A valid image publisher offer. </param> |
| | 589 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 590 | | public async Task<Response<IReadOnlyList<VirtualMachineImageResource>>> ListSkusAsync(string location, string pu |
| | 591 | | { |
| 4 | 592 | | if (location == null) |
| | 593 | | { |
| 0 | 594 | | throw new ArgumentNullException(nameof(location)); |
| | 595 | | } |
| 4 | 596 | | if (publisherName == null) |
| | 597 | | { |
| 0 | 598 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 599 | | } |
| 4 | 600 | | if (offer == null) |
| | 601 | | { |
| 0 | 602 | | throw new ArgumentNullException(nameof(offer)); |
| | 603 | | } |
| | 604 | |
|
| 4 | 605 | | using var message = CreateListSkusRequest(location, publisherName, offer); |
| 4 | 606 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 607 | | switch (message.Response.Status) |
| | 608 | | { |
| | 609 | | case 200: |
| | 610 | | { |
| 4 | 611 | | IReadOnlyList<VirtualMachineImageResource> value = default; |
| 4 | 612 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 613 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 614 | | { |
| 0 | 615 | | value = null; |
| | 616 | | } |
| | 617 | | else |
| | 618 | | { |
| 4 | 619 | | List<VirtualMachineImageResource> array = new List<VirtualMachineImageResource>(); |
| 364 | 620 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 621 | | { |
| 178 | 622 | | if (item.ValueKind == JsonValueKind.Null) |
| | 623 | | { |
| 0 | 624 | | array.Add(null); |
| | 625 | | } |
| | 626 | | else |
| | 627 | | { |
| 178 | 628 | | array.Add(VirtualMachineImageResource.DeserializeVirtualMachineImageResource(item)); |
| | 629 | | } |
| | 630 | | } |
| 4 | 631 | | value = array; |
| | 632 | | } |
| 4 | 633 | | return Response.FromValue(value, message.Response); |
| | 634 | | } |
| | 635 | | default: |
| 0 | 636 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 637 | | } |
| 4 | 638 | | } |
| | 639 | |
|
| | 640 | | /// <summary> Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. </summ |
| | 641 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 642 | | /// <param name="publisherName"> A valid image publisher. </param> |
| | 643 | | /// <param name="offer"> A valid image publisher offer. </param> |
| | 644 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 645 | | public Response<IReadOnlyList<VirtualMachineImageResource>> ListSkus(string location, string publisherName, stri |
| | 646 | | { |
| 4 | 647 | | if (location == null) |
| | 648 | | { |
| 0 | 649 | | throw new ArgumentNullException(nameof(location)); |
| | 650 | | } |
| 4 | 651 | | if (publisherName == null) |
| | 652 | | { |
| 0 | 653 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 654 | | } |
| 4 | 655 | | if (offer == null) |
| | 656 | | { |
| 0 | 657 | | throw new ArgumentNullException(nameof(offer)); |
| | 658 | | } |
| | 659 | |
|
| 4 | 660 | | using var message = CreateListSkusRequest(location, publisherName, offer); |
| 4 | 661 | | _pipeline.Send(message, cancellationToken); |
| 4 | 662 | | switch (message.Response.Status) |
| | 663 | | { |
| | 664 | | case 200: |
| | 665 | | { |
| 4 | 666 | | IReadOnlyList<VirtualMachineImageResource> value = default; |
| 4 | 667 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 668 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 669 | | { |
| 0 | 670 | | value = null; |
| | 671 | | } |
| | 672 | | else |
| | 673 | | { |
| 4 | 674 | | List<VirtualMachineImageResource> array = new List<VirtualMachineImageResource>(); |
| 364 | 675 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 676 | | { |
| 178 | 677 | | if (item.ValueKind == JsonValueKind.Null) |
| | 678 | | { |
| 0 | 679 | | array.Add(null); |
| | 680 | | } |
| | 681 | | else |
| | 682 | | { |
| 178 | 683 | | array.Add(VirtualMachineImageResource.DeserializeVirtualMachineImageResource(item)); |
| | 684 | | } |
| | 685 | | } |
| 4 | 686 | | value = array; |
| | 687 | | } |
| 4 | 688 | | return Response.FromValue(value, message.Response); |
| | 689 | | } |
| | 690 | | default: |
| 0 | 691 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 692 | | } |
| 4 | 693 | | } |
| | 694 | | } |
| | 695 | | } |