| | 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 ResourceSkusRestOperations |
| | 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 ResourceSkusRestOperations. </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 ResourceSkusRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio |
| | 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 filter) |
| | 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/skus", false); |
| 4 | 56 | | uri.AppendQuery("api-version", "2019-04-01", true); |
| 4 | 57 | | if (filter != null) |
| | 58 | | { |
| 0 | 59 | | uri.AppendQuery("$filter", filter, true); |
| | 60 | | } |
| 4 | 61 | | request.Uri = uri; |
| 4 | 62 | | return message; |
| | 63 | | } |
| | 64 | |
|
| | 65 | | /// <summary> Gets the list of Microsoft.Compute SKUs available for your Subscription. </summary> |
| | 66 | | /// <param name="filter"> The filter to apply on the operation. Only **location** filter is supported currently. |
| | 67 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 68 | | public async Task<Response<ResourceSkusResult>> ListAsync(string filter = null, CancellationToken cancellationTo |
| | 69 | | { |
| 2 | 70 | | using var message = CreateListRequest(filter); |
| 2 | 71 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 72 | | switch (message.Response.Status) |
| | 73 | | { |
| | 74 | | case 200: |
| | 75 | | { |
| 2 | 76 | | ResourceSkusResult value = default; |
| 2 | 77 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 78 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 79 | | { |
| 0 | 80 | | value = null; |
| | 81 | | } |
| | 82 | | else |
| | 83 | | { |
| 2 | 84 | | value = ResourceSkusResult.DeserializeResourceSkusResult(document.RootElement); |
| | 85 | | } |
| 2 | 86 | | return Response.FromValue(value, message.Response); |
| | 87 | | } |
| | 88 | | default: |
| 0 | 89 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 90 | | } |
| 2 | 91 | | } |
| | 92 | |
|
| | 93 | | /// <summary> Gets the list of Microsoft.Compute SKUs available for your Subscription. </summary> |
| | 94 | | /// <param name="filter"> The filter to apply on the operation. Only **location** filter is supported currently. |
| | 95 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 96 | | public Response<ResourceSkusResult> List(string filter = null, CancellationToken cancellationToken = default) |
| | 97 | | { |
| 2 | 98 | | using var message = CreateListRequest(filter); |
| 2 | 99 | | _pipeline.Send(message, cancellationToken); |
| 2 | 100 | | switch (message.Response.Status) |
| | 101 | | { |
| | 102 | | case 200: |
| | 103 | | { |
| 2 | 104 | | ResourceSkusResult value = default; |
| 2 | 105 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 106 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 107 | | { |
| 0 | 108 | | value = null; |
| | 109 | | } |
| | 110 | | else |
| | 111 | | { |
| 2 | 112 | | value = ResourceSkusResult.DeserializeResourceSkusResult(document.RootElement); |
| | 113 | | } |
| 2 | 114 | | return Response.FromValue(value, message.Response); |
| | 115 | | } |
| | 116 | | default: |
| 0 | 117 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 118 | | } |
| 2 | 119 | | } |
| | 120 | |
|
| | 121 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string filter) |
| | 122 | | { |
| 0 | 123 | | var message = _pipeline.CreateMessage(); |
| 0 | 124 | | var request = message.Request; |
| 0 | 125 | | request.Method = RequestMethod.Get; |
| 0 | 126 | | var uri = new RawRequestUriBuilder(); |
| 0 | 127 | | uri.Reset(endpoint); |
| 0 | 128 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 129 | | request.Uri = uri; |
| 0 | 130 | | return message; |
| | 131 | | } |
| | 132 | |
|
| | 133 | | /// <summary> Gets the list of Microsoft.Compute SKUs available for your Subscription. </summary> |
| | 134 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 135 | | /// <param name="filter"> The filter to apply on the operation. Only **location** filter is supported currently. |
| | 136 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 137 | | public async Task<Response<ResourceSkusResult>> ListNextPageAsync(string nextLink, string filter = null, Cancell |
| | 138 | | { |
| 0 | 139 | | if (nextLink == null) |
| | 140 | | { |
| 0 | 141 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 142 | | } |
| | 143 | |
|
| 0 | 144 | | using var message = CreateListNextPageRequest(nextLink, filter); |
| 0 | 145 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 146 | | switch (message.Response.Status) |
| | 147 | | { |
| | 148 | | case 200: |
| | 149 | | { |
| 0 | 150 | | ResourceSkusResult value = default; |
| 0 | 151 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 152 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 153 | | { |
| 0 | 154 | | value = null; |
| | 155 | | } |
| | 156 | | else |
| | 157 | | { |
| 0 | 158 | | value = ResourceSkusResult.DeserializeResourceSkusResult(document.RootElement); |
| | 159 | | } |
| 0 | 160 | | return Response.FromValue(value, message.Response); |
| | 161 | | } |
| | 162 | | default: |
| 0 | 163 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 164 | | } |
| 0 | 165 | | } |
| | 166 | |
|
| | 167 | | /// <summary> Gets the list of Microsoft.Compute SKUs available for your Subscription. </summary> |
| | 168 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 169 | | /// <param name="filter"> The filter to apply on the operation. Only **location** filter is supported currently. |
| | 170 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 171 | | public Response<ResourceSkusResult> ListNextPage(string nextLink, string filter = null, CancellationToken cancel |
| | 172 | | { |
| 0 | 173 | | if (nextLink == null) |
| | 174 | | { |
| 0 | 175 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 176 | | } |
| | 177 | |
|
| 0 | 178 | | using var message = CreateListNextPageRequest(nextLink, filter); |
| 0 | 179 | | _pipeline.Send(message, cancellationToken); |
| 0 | 180 | | switch (message.Response.Status) |
| | 181 | | { |
| | 182 | | case 200: |
| | 183 | | { |
| 0 | 184 | | ResourceSkusResult value = default; |
| 0 | 185 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 186 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 187 | | { |
| 0 | 188 | | value = null; |
| | 189 | | } |
| | 190 | | else |
| | 191 | | { |
| 0 | 192 | | value = ResourceSkusResult.DeserializeResourceSkusResult(document.RootElement); |
| | 193 | | } |
| 0 | 194 | | return Response.FromValue(value, message.Response); |
| | 195 | | } |
| | 196 | | default: |
| 0 | 197 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 198 | | } |
| 0 | 199 | | } |
| | 200 | | } |
| | 201 | | } |