| | | 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 VirtualMachineSizesRestOperations |
| | | 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 VirtualMachineSizesRestOperations. </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 VirtualMachineSizesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subs |
| | | 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 CreateListRequest(string location) |
| | | 47 | | { |
| | 4 | 48 | | var message = _pipeline.CreateMessage(); |
| | 4 | 49 | | var request = message.Request; |
| | 4 | 50 | | request.Method = RequestMethod.Get; |
| | 4 | 51 | | var uri = new RawRequestUriBuilder(); |
| | 4 | 52 | | uri.Reset(endpoint); |
| | 4 | 53 | | uri.AppendPath("/subscriptions/", false); |
| | 4 | 54 | | uri.AppendPath(subscriptionId, true); |
| | 4 | 55 | | uri.AppendPath("/providers/Microsoft.Compute/locations/", false); |
| | 4 | 56 | | uri.AppendPath(location, true); |
| | 4 | 57 | | uri.AppendPath("/vmSizes", false); |
| | 4 | 58 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| | 4 | 59 | | request.Uri = uri; |
| | 4 | 60 | | return message; |
| | | 61 | | } |
| | | 62 | | |
| | | 63 | | /// <summary> This API is deprecated. Use [Resources Skus](https://docs.microsoft.com/en-us/rest/api/compute/res |
| | | 64 | | /// <param name="location"> The location upon which virtual-machine-sizes is queried. </param> |
| | | 65 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 66 | | public async Task<Response<VirtualMachineSizeListResult>> ListAsync(string location, CancellationToken cancellat |
| | | 67 | | { |
| | 2 | 68 | | if (location == null) |
| | | 69 | | { |
| | 0 | 70 | | throw new ArgumentNullException(nameof(location)); |
| | | 71 | | } |
| | | 72 | | |
| | 2 | 73 | | using var message = CreateListRequest(location); |
| | 2 | 74 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 2 | 75 | | switch (message.Response.Status) |
| | | 76 | | { |
| | | 77 | | case 200: |
| | | 78 | | { |
| | 2 | 79 | | VirtualMachineSizeListResult value = default; |
| | 2 | 80 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 2 | 81 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 82 | | { |
| | 0 | 83 | | value = null; |
| | | 84 | | } |
| | | 85 | | else |
| | | 86 | | { |
| | 2 | 87 | | value = VirtualMachineSizeListResult.DeserializeVirtualMachineSizeListResult(document.RootEl |
| | | 88 | | } |
| | 2 | 89 | | return Response.FromValue(value, message.Response); |
| | | 90 | | } |
| | | 91 | | default: |
| | 0 | 92 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 93 | | } |
| | 2 | 94 | | } |
| | | 95 | | |
| | | 96 | | /// <summary> This API is deprecated. Use [Resources Skus](https://docs.microsoft.com/en-us/rest/api/compute/res |
| | | 97 | | /// <param name="location"> The location upon which virtual-machine-sizes is queried. </param> |
| | | 98 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 99 | | public Response<VirtualMachineSizeListResult> List(string location, CancellationToken cancellationToken = defaul |
| | | 100 | | { |
| | 2 | 101 | | if (location == null) |
| | | 102 | | { |
| | 0 | 103 | | throw new ArgumentNullException(nameof(location)); |
| | | 104 | | } |
| | | 105 | | |
| | 2 | 106 | | using var message = CreateListRequest(location); |
| | 2 | 107 | | _pipeline.Send(message, cancellationToken); |
| | 2 | 108 | | switch (message.Response.Status) |
| | | 109 | | { |
| | | 110 | | case 200: |
| | | 111 | | { |
| | 2 | 112 | | VirtualMachineSizeListResult value = default; |
| | 2 | 113 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 2 | 114 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 115 | | { |
| | 0 | 116 | | value = null; |
| | | 117 | | } |
| | | 118 | | else |
| | | 119 | | { |
| | 2 | 120 | | value = VirtualMachineSizeListResult.DeserializeVirtualMachineSizeListResult(document.RootEl |
| | | 121 | | } |
| | 2 | 122 | | return Response.FromValue(value, message.Response); |
| | | 123 | | } |
| | | 124 | | default: |
| | 0 | 125 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 126 | | } |
| | 2 | 127 | | } |
| | | 128 | | } |
| | | 129 | | } |