| | 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.Network.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Network |
| | 18 | | { |
| | 19 | | internal partial class ExpressRoutePortsLocationsRestOperations |
| | 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 ExpressRoutePortsLocationsRestOperations. </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"> The subscription credentials which uniquely identify the Microsoft Azure subsc |
| | 30 | | /// <param name="endpoint"> server parameter. </param> |
| | 31 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 0 | 32 | | public ExpressRoutePortsLocationsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, stri |
| | 33 | | { |
| 0 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 0 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 0 | 40 | | this.subscriptionId = subscriptionId; |
| 0 | 41 | | this.endpoint = endpoint; |
| 0 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 43 | | _pipeline = pipeline; |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateListRequest() |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Get; |
| 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("/providers/Microsoft.Network/ExpressRoutePortsLocations", false); |
| 0 | 56 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 57 | | request.Uri = uri; |
| 0 | 58 | | return message; |
| | 59 | | } |
| | 60 | |
|
| | 61 | | /// <summary> Retrieves all ExpressRoutePort peering locations. Does not return available bandwidths for each lo |
| | 62 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 63 | | public async Task<Response<ExpressRoutePortsLocationListResult>> ListAsync(CancellationToken cancellationToken = |
| | 64 | | { |
| 0 | 65 | | using var message = CreateListRequest(); |
| 0 | 66 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 67 | | switch (message.Response.Status) |
| | 68 | | { |
| | 69 | | case 200: |
| | 70 | | { |
| 0 | 71 | | ExpressRoutePortsLocationListResult value = default; |
| 0 | 72 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 73 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 74 | | { |
| 0 | 75 | | value = null; |
| | 76 | | } |
| | 77 | | else |
| | 78 | | { |
| 0 | 79 | | value = ExpressRoutePortsLocationListResult.DeserializeExpressRoutePortsLocationListResult(d |
| | 80 | | } |
| 0 | 81 | | return Response.FromValue(value, message.Response); |
| | 82 | | } |
| | 83 | | default: |
| 0 | 84 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 85 | | } |
| 0 | 86 | | } |
| | 87 | |
|
| | 88 | | /// <summary> Retrieves all ExpressRoutePort peering locations. Does not return available bandwidths for each lo |
| | 89 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 90 | | public Response<ExpressRoutePortsLocationListResult> List(CancellationToken cancellationToken = default) |
| | 91 | | { |
| 0 | 92 | | using var message = CreateListRequest(); |
| 0 | 93 | | _pipeline.Send(message, cancellationToken); |
| 0 | 94 | | switch (message.Response.Status) |
| | 95 | | { |
| | 96 | | case 200: |
| | 97 | | { |
| 0 | 98 | | ExpressRoutePortsLocationListResult value = default; |
| 0 | 99 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 100 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 101 | | { |
| 0 | 102 | | value = null; |
| | 103 | | } |
| | 104 | | else |
| | 105 | | { |
| 0 | 106 | | value = ExpressRoutePortsLocationListResult.DeserializeExpressRoutePortsLocationListResult(d |
| | 107 | | } |
| 0 | 108 | | return Response.FromValue(value, message.Response); |
| | 109 | | } |
| | 110 | | default: |
| 0 | 111 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 112 | | } |
| 0 | 113 | | } |
| | 114 | |
|
| | 115 | | internal HttpMessage CreateGetRequest(string locationName) |
| | 116 | | { |
| 0 | 117 | | var message = _pipeline.CreateMessage(); |
| 0 | 118 | | var request = message.Request; |
| 0 | 119 | | request.Method = RequestMethod.Get; |
| 0 | 120 | | var uri = new RawRequestUriBuilder(); |
| 0 | 121 | | uri.Reset(endpoint); |
| 0 | 122 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 123 | | uri.AppendPath(subscriptionId, true); |
| 0 | 124 | | uri.AppendPath("/providers/Microsoft.Network/ExpressRoutePortsLocations/", false); |
| 0 | 125 | | uri.AppendPath(locationName, true); |
| 0 | 126 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 127 | | request.Uri = uri; |
| 0 | 128 | | return message; |
| | 129 | | } |
| | 130 | |
|
| | 131 | | /// <summary> Retrieves a single ExpressRoutePort peering location, including the list of available bandwidths a |
| | 132 | | /// <param name="locationName"> Name of the requested ExpressRoutePort peering location. </param> |
| | 133 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 134 | | public async Task<Response<ExpressRoutePortsLocation>> GetAsync(string locationName, CancellationToken cancellat |
| | 135 | | { |
| 0 | 136 | | if (locationName == null) |
| | 137 | | { |
| 0 | 138 | | throw new ArgumentNullException(nameof(locationName)); |
| | 139 | | } |
| | 140 | |
|
| 0 | 141 | | using var message = CreateGetRequest(locationName); |
| 0 | 142 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 143 | | switch (message.Response.Status) |
| | 144 | | { |
| | 145 | | case 200: |
| | 146 | | { |
| 0 | 147 | | ExpressRoutePortsLocation value = default; |
| 0 | 148 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 149 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 150 | | { |
| 0 | 151 | | value = null; |
| | 152 | | } |
| | 153 | | else |
| | 154 | | { |
| 0 | 155 | | value = ExpressRoutePortsLocation.DeserializeExpressRoutePortsLocation(document.RootElement) |
| | 156 | | } |
| 0 | 157 | | return Response.FromValue(value, message.Response); |
| | 158 | | } |
| | 159 | | default: |
| 0 | 160 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 161 | | } |
| 0 | 162 | | } |
| | 163 | |
|
| | 164 | | /// <summary> Retrieves a single ExpressRoutePort peering location, including the list of available bandwidths a |
| | 165 | | /// <param name="locationName"> Name of the requested ExpressRoutePort peering location. </param> |
| | 166 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 167 | | public Response<ExpressRoutePortsLocation> Get(string locationName, CancellationToken cancellationToken = defaul |
| | 168 | | { |
| 0 | 169 | | if (locationName == null) |
| | 170 | | { |
| 0 | 171 | | throw new ArgumentNullException(nameof(locationName)); |
| | 172 | | } |
| | 173 | |
|
| 0 | 174 | | using var message = CreateGetRequest(locationName); |
| 0 | 175 | | _pipeline.Send(message, cancellationToken); |
| 0 | 176 | | switch (message.Response.Status) |
| | 177 | | { |
| | 178 | | case 200: |
| | 179 | | { |
| 0 | 180 | | ExpressRoutePortsLocation value = default; |
| 0 | 181 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 182 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 183 | | { |
| 0 | 184 | | value = null; |
| | 185 | | } |
| | 186 | | else |
| | 187 | | { |
| 0 | 188 | | value = ExpressRoutePortsLocation.DeserializeExpressRoutePortsLocation(document.RootElement) |
| | 189 | | } |
| 0 | 190 | | return Response.FromValue(value, message.Response); |
| | 191 | | } |
| | 192 | | default: |
| 0 | 193 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 194 | | } |
| 0 | 195 | | } |
| | 196 | |
|
| | 197 | | internal HttpMessage CreateListNextPageRequest(string nextLink) |
| | 198 | | { |
| 0 | 199 | | var message = _pipeline.CreateMessage(); |
| 0 | 200 | | var request = message.Request; |
| 0 | 201 | | request.Method = RequestMethod.Get; |
| 0 | 202 | | var uri = new RawRequestUriBuilder(); |
| 0 | 203 | | uri.Reset(endpoint); |
| 0 | 204 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 205 | | request.Uri = uri; |
| 0 | 206 | | return message; |
| | 207 | | } |
| | 208 | |
|
| | 209 | | /// <summary> Retrieves all ExpressRoutePort peering locations. Does not return available bandwidths for each lo |
| | 210 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 211 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 212 | | public async Task<Response<ExpressRoutePortsLocationListResult>> ListNextPageAsync(string nextLink, Cancellation |
| | 213 | | { |
| 0 | 214 | | if (nextLink == null) |
| | 215 | | { |
| 0 | 216 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 217 | | } |
| | 218 | |
|
| 0 | 219 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 220 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 221 | | switch (message.Response.Status) |
| | 222 | | { |
| | 223 | | case 200: |
| | 224 | | { |
| 0 | 225 | | ExpressRoutePortsLocationListResult value = default; |
| 0 | 226 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 227 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 228 | | { |
| 0 | 229 | | value = null; |
| | 230 | | } |
| | 231 | | else |
| | 232 | | { |
| 0 | 233 | | value = ExpressRoutePortsLocationListResult.DeserializeExpressRoutePortsLocationListResult(d |
| | 234 | | } |
| 0 | 235 | | return Response.FromValue(value, message.Response); |
| | 236 | | } |
| | 237 | | default: |
| 0 | 238 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 239 | | } |
| 0 | 240 | | } |
| | 241 | |
|
| | 242 | | /// <summary> Retrieves all ExpressRoutePort peering locations. Does not return available bandwidths for each lo |
| | 243 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 244 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 245 | | public Response<ExpressRoutePortsLocationListResult> ListNextPage(string nextLink, CancellationToken cancellatio |
| | 246 | | { |
| 0 | 247 | | if (nextLink == null) |
| | 248 | | { |
| 0 | 249 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 250 | | } |
| | 251 | |
|
| 0 | 252 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 253 | | _pipeline.Send(message, cancellationToken); |
| 0 | 254 | | switch (message.Response.Status) |
| | 255 | | { |
| | 256 | | case 200: |
| | 257 | | { |
| 0 | 258 | | ExpressRoutePortsLocationListResult value = default; |
| 0 | 259 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 260 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 261 | | { |
| 0 | 262 | | value = null; |
| | 263 | | } |
| | 264 | | else |
| | 265 | | { |
| 0 | 266 | | value = ExpressRoutePortsLocationListResult.DeserializeExpressRoutePortsLocationListResult(d |
| | 267 | | } |
| 0 | 268 | | return Response.FromValue(value, message.Response); |
| | 269 | | } |
| | 270 | | default: |
| 0 | 271 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 272 | | } |
| 0 | 273 | | } |
| | 274 | | } |
| | 275 | | } |