| | 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 VirtualNetworksRestOperations |
| | 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 VirtualNetworksRestOperations. </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 |
| 280 | 32 | | public VirtualNetworksRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscrip |
| | 33 | | { |
| 280 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 280 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 280 | 40 | | this.subscriptionId = subscriptionId; |
| 280 | 41 | | this.endpoint = endpoint; |
| 280 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 280 | 43 | | _pipeline = pipeline; |
| 280 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string virtualNetworkName) |
| | 47 | | { |
| 152 | 48 | | var message = _pipeline.CreateMessage(); |
| 152 | 49 | | var request = message.Request; |
| 152 | 50 | | request.Method = RequestMethod.Delete; |
| 152 | 51 | | var uri = new RawRequestUriBuilder(); |
| 152 | 52 | | uri.Reset(endpoint); |
| 152 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 152 | 54 | | uri.AppendPath(subscriptionId, true); |
| 152 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 152 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 152 | 57 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false); |
| 152 | 58 | | uri.AppendPath(virtualNetworkName, true); |
| 152 | 59 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 152 | 60 | | request.Uri = uri; |
| 152 | 61 | | return message; |
| | 62 | | } |
| | 63 | |
|
| | 64 | | /// <summary> Deletes the specified virtual network. </summary> |
| | 65 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 66 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 67 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 68 | | public async Task<Response> DeleteAsync(string resourceGroupName, string virtualNetworkName, CancellationToken c |
| | 69 | | { |
| 38 | 70 | | if (resourceGroupName == null) |
| | 71 | | { |
| 0 | 72 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 73 | | } |
| 38 | 74 | | if (virtualNetworkName == null) |
| | 75 | | { |
| 0 | 76 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 77 | | } |
| | 78 | |
|
| 38 | 79 | | using var message = CreateDeleteRequest(resourceGroupName, virtualNetworkName); |
| 38 | 80 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 38 | 81 | | switch (message.Response.Status) |
| | 82 | | { |
| | 83 | | case 200: |
| | 84 | | case 202: |
| | 85 | | case 204: |
| 38 | 86 | | return message.Response; |
| | 87 | | default: |
| 0 | 88 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 89 | | } |
| 38 | 90 | | } |
| | 91 | |
|
| | 92 | | /// <summary> Deletes the specified virtual network. </summary> |
| | 93 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 94 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 95 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 96 | | public Response Delete(string resourceGroupName, string virtualNetworkName, CancellationToken cancellationToken |
| | 97 | | { |
| 38 | 98 | | if (resourceGroupName == null) |
| | 99 | | { |
| 0 | 100 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 101 | | } |
| 38 | 102 | | if (virtualNetworkName == null) |
| | 103 | | { |
| 0 | 104 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 105 | | } |
| | 106 | |
|
| 38 | 107 | | using var message = CreateDeleteRequest(resourceGroupName, virtualNetworkName); |
| 38 | 108 | | _pipeline.Send(message, cancellationToken); |
| 38 | 109 | | switch (message.Response.Status) |
| | 110 | | { |
| | 111 | | case 200: |
| | 112 | | case 202: |
| | 113 | | case 204: |
| 38 | 114 | | return message.Response; |
| | 115 | | default: |
| 0 | 116 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 117 | | } |
| 38 | 118 | | } |
| | 119 | |
|
| | 120 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string virtualNetworkName, string expand) |
| | 121 | | { |
| 60 | 122 | | var message = _pipeline.CreateMessage(); |
| 60 | 123 | | var request = message.Request; |
| 60 | 124 | | request.Method = RequestMethod.Get; |
| 60 | 125 | | var uri = new RawRequestUriBuilder(); |
| 60 | 126 | | uri.Reset(endpoint); |
| 60 | 127 | | uri.AppendPath("/subscriptions/", false); |
| 60 | 128 | | uri.AppendPath(subscriptionId, true); |
| 60 | 129 | | uri.AppendPath("/resourceGroups/", false); |
| 60 | 130 | | uri.AppendPath(resourceGroupName, true); |
| 60 | 131 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false); |
| 60 | 132 | | uri.AppendPath(virtualNetworkName, true); |
| 60 | 133 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 60 | 134 | | if (expand != null) |
| | 135 | | { |
| 0 | 136 | | uri.AppendQuery("$expand", expand, true); |
| | 137 | | } |
| 60 | 138 | | request.Uri = uri; |
| 60 | 139 | | return message; |
| | 140 | | } |
| | 141 | |
|
| | 142 | | /// <summary> Gets the specified virtual network by resource group. </summary> |
| | 143 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 144 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 145 | | /// <param name="expand"> Expands referenced resources. </param> |
| | 146 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 147 | | public async Task<Response<VirtualNetwork>> GetAsync(string resourceGroupName, string virtualNetworkName, string |
| | 148 | | { |
| 30 | 149 | | if (resourceGroupName == null) |
| | 150 | | { |
| 0 | 151 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 152 | | } |
| 30 | 153 | | if (virtualNetworkName == null) |
| | 154 | | { |
| 0 | 155 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 156 | | } |
| | 157 | |
|
| 30 | 158 | | using var message = CreateGetRequest(resourceGroupName, virtualNetworkName, expand); |
| 30 | 159 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 30 | 160 | | switch (message.Response.Status) |
| | 161 | | { |
| | 162 | | case 200: |
| | 163 | | { |
| 30 | 164 | | VirtualNetwork value = default; |
| 30 | 165 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 30 | 166 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 167 | | { |
| 0 | 168 | | value = null; |
| | 169 | | } |
| | 170 | | else |
| | 171 | | { |
| 30 | 172 | | value = VirtualNetwork.DeserializeVirtualNetwork(document.RootElement); |
| | 173 | | } |
| 30 | 174 | | return Response.FromValue(value, message.Response); |
| | 175 | | } |
| | 176 | | default: |
| 0 | 177 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 178 | | } |
| 30 | 179 | | } |
| | 180 | |
|
| | 181 | | /// <summary> Gets the specified virtual network by resource group. </summary> |
| | 182 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 183 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 184 | | /// <param name="expand"> Expands referenced resources. </param> |
| | 185 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 186 | | public Response<VirtualNetwork> Get(string resourceGroupName, string virtualNetworkName, string expand = null, C |
| | 187 | | { |
| 30 | 188 | | if (resourceGroupName == null) |
| | 189 | | { |
| 0 | 190 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 191 | | } |
| 30 | 192 | | if (virtualNetworkName == null) |
| | 193 | | { |
| 0 | 194 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 195 | | } |
| | 196 | |
|
| 30 | 197 | | using var message = CreateGetRequest(resourceGroupName, virtualNetworkName, expand); |
| 30 | 198 | | _pipeline.Send(message, cancellationToken); |
| 30 | 199 | | switch (message.Response.Status) |
| | 200 | | { |
| | 201 | | case 200: |
| | 202 | | { |
| 30 | 203 | | VirtualNetwork value = default; |
| 30 | 204 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 30 | 205 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 206 | | { |
| 0 | 207 | | value = null; |
| | 208 | | } |
| | 209 | | else |
| | 210 | | { |
| 30 | 211 | | value = VirtualNetwork.DeserializeVirtualNetwork(document.RootElement); |
| | 212 | | } |
| 30 | 213 | | return Response.FromValue(value, message.Response); |
| | 214 | | } |
| | 215 | | default: |
| 0 | 216 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 217 | | } |
| 30 | 218 | | } |
| | 219 | |
|
| | 220 | | internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string virtualNetworkName, VirtualNet |
| | 221 | | { |
| 216 | 222 | | var message = _pipeline.CreateMessage(); |
| 216 | 223 | | var request = message.Request; |
| 216 | 224 | | request.Method = RequestMethod.Put; |
| 216 | 225 | | var uri = new RawRequestUriBuilder(); |
| 216 | 226 | | uri.Reset(endpoint); |
| 216 | 227 | | uri.AppendPath("/subscriptions/", false); |
| 216 | 228 | | uri.AppendPath(subscriptionId, true); |
| 216 | 229 | | uri.AppendPath("/resourceGroups/", false); |
| 216 | 230 | | uri.AppendPath(resourceGroupName, true); |
| 216 | 231 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false); |
| 216 | 232 | | uri.AppendPath(virtualNetworkName, true); |
| 216 | 233 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 216 | 234 | | request.Uri = uri; |
| 216 | 235 | | request.Headers.Add("Content-Type", "application/json"); |
| 216 | 236 | | var content = new Utf8JsonRequestContent(); |
| 216 | 237 | | content.JsonWriter.WriteObjectValue(parameters); |
| 216 | 238 | | request.Content = content; |
| 216 | 239 | | return message; |
| | 240 | | } |
| | 241 | |
|
| | 242 | | /// <summary> Creates or updates a virtual network in the specified resource group. </summary> |
| | 243 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 244 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 245 | | /// <param name="parameters"> Parameters supplied to the create or update virtual network operation. </param> |
| | 246 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 247 | | public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string virtualNetworkName, VirtualNetw |
| | 248 | | { |
| 54 | 249 | | if (resourceGroupName == null) |
| | 250 | | { |
| 0 | 251 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 252 | | } |
| 54 | 253 | | if (virtualNetworkName == null) |
| | 254 | | { |
| 0 | 255 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 256 | | } |
| 54 | 257 | | if (parameters == null) |
| | 258 | | { |
| 0 | 259 | | throw new ArgumentNullException(nameof(parameters)); |
| | 260 | | } |
| | 261 | |
|
| 54 | 262 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualNetworkName, parameters); |
| 54 | 263 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 54 | 264 | | switch (message.Response.Status) |
| | 265 | | { |
| | 266 | | case 200: |
| | 267 | | case 201: |
| 54 | 268 | | return message.Response; |
| | 269 | | default: |
| 0 | 270 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 271 | | } |
| 54 | 272 | | } |
| | 273 | |
|
| | 274 | | /// <summary> Creates or updates a virtual network in the specified resource group. </summary> |
| | 275 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 276 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 277 | | /// <param name="parameters"> Parameters supplied to the create or update virtual network operation. </param> |
| | 278 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 279 | | public Response CreateOrUpdate(string resourceGroupName, string virtualNetworkName, VirtualNetwork parameters, C |
| | 280 | | { |
| 54 | 281 | | if (resourceGroupName == null) |
| | 282 | | { |
| 0 | 283 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 284 | | } |
| 54 | 285 | | if (virtualNetworkName == null) |
| | 286 | | { |
| 0 | 287 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 288 | | } |
| 54 | 289 | | if (parameters == null) |
| | 290 | | { |
| 0 | 291 | | throw new ArgumentNullException(nameof(parameters)); |
| | 292 | | } |
| | 293 | |
|
| 54 | 294 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualNetworkName, parameters); |
| 54 | 295 | | _pipeline.Send(message, cancellationToken); |
| 54 | 296 | | switch (message.Response.Status) |
| | 297 | | { |
| | 298 | | case 200: |
| | 299 | | case 201: |
| 54 | 300 | | return message.Response; |
| | 301 | | default: |
| 0 | 302 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 303 | | } |
| 54 | 304 | | } |
| | 305 | |
|
| | 306 | | internal HttpMessage CreateUpdateTagsRequest(string resourceGroupName, string virtualNetworkName, TagsObject par |
| | 307 | | { |
| 0 | 308 | | var message = _pipeline.CreateMessage(); |
| 0 | 309 | | var request = message.Request; |
| 0 | 310 | | request.Method = RequestMethod.Patch; |
| 0 | 311 | | var uri = new RawRequestUriBuilder(); |
| 0 | 312 | | uri.Reset(endpoint); |
| 0 | 313 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 314 | | uri.AppendPath(subscriptionId, true); |
| 0 | 315 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 316 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 317 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false); |
| 0 | 318 | | uri.AppendPath(virtualNetworkName, true); |
| 0 | 319 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 320 | | request.Uri = uri; |
| 0 | 321 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 322 | | var content = new Utf8JsonRequestContent(); |
| 0 | 323 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 324 | | request.Content = content; |
| 0 | 325 | | return message; |
| | 326 | | } |
| | 327 | |
|
| | 328 | | /// <summary> Updates a virtual network tags. </summary> |
| | 329 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 330 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 331 | | /// <param name="parameters"> Parameters supplied to update virtual network tags. </param> |
| | 332 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 333 | | public async Task<Response<VirtualNetwork>> UpdateTagsAsync(string resourceGroupName, string virtualNetworkName, |
| | 334 | | { |
| 0 | 335 | | if (resourceGroupName == null) |
| | 336 | | { |
| 0 | 337 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 338 | | } |
| 0 | 339 | | if (virtualNetworkName == null) |
| | 340 | | { |
| 0 | 341 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 342 | | } |
| 0 | 343 | | if (parameters == null) |
| | 344 | | { |
| 0 | 345 | | throw new ArgumentNullException(nameof(parameters)); |
| | 346 | | } |
| | 347 | |
|
| 0 | 348 | | using var message = CreateUpdateTagsRequest(resourceGroupName, virtualNetworkName, parameters); |
| 0 | 349 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 350 | | switch (message.Response.Status) |
| | 351 | | { |
| | 352 | | case 200: |
| | 353 | | { |
| 0 | 354 | | VirtualNetwork value = default; |
| 0 | 355 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 356 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 357 | | { |
| 0 | 358 | | value = null; |
| | 359 | | } |
| | 360 | | else |
| | 361 | | { |
| 0 | 362 | | value = VirtualNetwork.DeserializeVirtualNetwork(document.RootElement); |
| | 363 | | } |
| 0 | 364 | | return Response.FromValue(value, message.Response); |
| | 365 | | } |
| | 366 | | default: |
| 0 | 367 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 368 | | } |
| 0 | 369 | | } |
| | 370 | |
|
| | 371 | | /// <summary> Updates a virtual network tags. </summary> |
| | 372 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 373 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 374 | | /// <param name="parameters"> Parameters supplied to update virtual network tags. </param> |
| | 375 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 376 | | public Response<VirtualNetwork> UpdateTags(string resourceGroupName, string virtualNetworkName, TagsObject param |
| | 377 | | { |
| 0 | 378 | | if (resourceGroupName == null) |
| | 379 | | { |
| 0 | 380 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 381 | | } |
| 0 | 382 | | if (virtualNetworkName == null) |
| | 383 | | { |
| 0 | 384 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 385 | | } |
| 0 | 386 | | if (parameters == null) |
| | 387 | | { |
| 0 | 388 | | throw new ArgumentNullException(nameof(parameters)); |
| | 389 | | } |
| | 390 | |
|
| 0 | 391 | | using var message = CreateUpdateTagsRequest(resourceGroupName, virtualNetworkName, parameters); |
| 0 | 392 | | _pipeline.Send(message, cancellationToken); |
| 0 | 393 | | switch (message.Response.Status) |
| | 394 | | { |
| | 395 | | case 200: |
| | 396 | | { |
| 0 | 397 | | VirtualNetwork value = default; |
| 0 | 398 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 399 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 400 | | { |
| 0 | 401 | | value = null; |
| | 402 | | } |
| | 403 | | else |
| | 404 | | { |
| 0 | 405 | | value = VirtualNetwork.DeserializeVirtualNetwork(document.RootElement); |
| | 406 | | } |
| 0 | 407 | | return Response.FromValue(value, message.Response); |
| | 408 | | } |
| | 409 | | default: |
| 0 | 410 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 411 | | } |
| 0 | 412 | | } |
| | 413 | |
|
| | 414 | | internal HttpMessage CreateListAllRequest() |
| | 415 | | { |
| 4 | 416 | | var message = _pipeline.CreateMessage(); |
| 4 | 417 | | var request = message.Request; |
| 4 | 418 | | request.Method = RequestMethod.Get; |
| 4 | 419 | | var uri = new RawRequestUriBuilder(); |
| 4 | 420 | | uri.Reset(endpoint); |
| 4 | 421 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 422 | | uri.AppendPath(subscriptionId, true); |
| 4 | 423 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks", false); |
| 4 | 424 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 4 | 425 | | request.Uri = uri; |
| 4 | 426 | | return message; |
| | 427 | | } |
| | 428 | |
|
| | 429 | | /// <summary> Gets all virtual networks in a subscription. </summary> |
| | 430 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 431 | | public async Task<Response<VirtualNetworkListResult>> ListAllAsync(CancellationToken cancellationToken = default |
| | 432 | | { |
| 2 | 433 | | using var message = CreateListAllRequest(); |
| 2 | 434 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 435 | | switch (message.Response.Status) |
| | 436 | | { |
| | 437 | | case 200: |
| | 438 | | { |
| 2 | 439 | | VirtualNetworkListResult value = default; |
| 2 | 440 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 441 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 442 | | { |
| 0 | 443 | | value = null; |
| | 444 | | } |
| | 445 | | else |
| | 446 | | { |
| 2 | 447 | | value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement); |
| | 448 | | } |
| 2 | 449 | | return Response.FromValue(value, message.Response); |
| | 450 | | } |
| | 451 | | default: |
| 0 | 452 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 453 | | } |
| 2 | 454 | | } |
| | 455 | |
|
| | 456 | | /// <summary> Gets all virtual networks in a subscription. </summary> |
| | 457 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 458 | | public Response<VirtualNetworkListResult> ListAll(CancellationToken cancellationToken = default) |
| | 459 | | { |
| 2 | 460 | | using var message = CreateListAllRequest(); |
| 2 | 461 | | _pipeline.Send(message, cancellationToken); |
| 2 | 462 | | switch (message.Response.Status) |
| | 463 | | { |
| | 464 | | case 200: |
| | 465 | | { |
| 2 | 466 | | VirtualNetworkListResult value = default; |
| 2 | 467 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 468 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 469 | | { |
| 0 | 470 | | value = null; |
| | 471 | | } |
| | 472 | | else |
| | 473 | | { |
| 2 | 474 | | value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement); |
| | 475 | | } |
| 2 | 476 | | return Response.FromValue(value, message.Response); |
| | 477 | | } |
| | 478 | | default: |
| 0 | 479 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 480 | | } |
| 2 | 481 | | } |
| | 482 | |
|
| | 483 | | internal HttpMessage CreateListRequest(string resourceGroupName) |
| | 484 | | { |
| 16 | 485 | | var message = _pipeline.CreateMessage(); |
| 16 | 486 | | var request = message.Request; |
| 16 | 487 | | request.Method = RequestMethod.Get; |
| 16 | 488 | | var uri = new RawRequestUriBuilder(); |
| 16 | 489 | | uri.Reset(endpoint); |
| 16 | 490 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 491 | | uri.AppendPath(subscriptionId, true); |
| 16 | 492 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 493 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 494 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks", false); |
| 16 | 495 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 16 | 496 | | request.Uri = uri; |
| 16 | 497 | | return message; |
| | 498 | | } |
| | 499 | |
|
| | 500 | | /// <summary> Gets all virtual networks in a resource group. </summary> |
| | 501 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 502 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 503 | | public async Task<Response<VirtualNetworkListResult>> ListAsync(string resourceGroupName, CancellationToken canc |
| | 504 | | { |
| 8 | 505 | | if (resourceGroupName == null) |
| | 506 | | { |
| 0 | 507 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 508 | | } |
| | 509 | |
|
| 8 | 510 | | using var message = CreateListRequest(resourceGroupName); |
| 8 | 511 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 8 | 512 | | switch (message.Response.Status) |
| | 513 | | { |
| | 514 | | case 200: |
| | 515 | | { |
| 8 | 516 | | VirtualNetworkListResult value = default; |
| 8 | 517 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 8 | 518 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 519 | | { |
| 0 | 520 | | value = null; |
| | 521 | | } |
| | 522 | | else |
| | 523 | | { |
| 8 | 524 | | value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement); |
| | 525 | | } |
| 8 | 526 | | return Response.FromValue(value, message.Response); |
| | 527 | | } |
| | 528 | | default: |
| 0 | 529 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 530 | | } |
| 8 | 531 | | } |
| | 532 | |
|
| | 533 | | /// <summary> Gets all virtual networks in a resource group. </summary> |
| | 534 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 535 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 536 | | public Response<VirtualNetworkListResult> List(string resourceGroupName, CancellationToken cancellationToken = d |
| | 537 | | { |
| 8 | 538 | | if (resourceGroupName == null) |
| | 539 | | { |
| 0 | 540 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 541 | | } |
| | 542 | |
|
| 8 | 543 | | using var message = CreateListRequest(resourceGroupName); |
| 8 | 544 | | _pipeline.Send(message, cancellationToken); |
| 8 | 545 | | switch (message.Response.Status) |
| | 546 | | { |
| | 547 | | case 200: |
| | 548 | | { |
| 8 | 549 | | VirtualNetworkListResult value = default; |
| 8 | 550 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 8 | 551 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 552 | | { |
| 0 | 553 | | value = null; |
| | 554 | | } |
| | 555 | | else |
| | 556 | | { |
| 8 | 557 | | value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement); |
| | 558 | | } |
| 8 | 559 | | return Response.FromValue(value, message.Response); |
| | 560 | | } |
| | 561 | | default: |
| 0 | 562 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 563 | | } |
| 8 | 564 | | } |
| | 565 | |
|
| | 566 | | internal HttpMessage CreateCheckIPAddressAvailabilityRequest(string resourceGroupName, string virtualNetworkName |
| | 567 | | { |
| 8 | 568 | | var message = _pipeline.CreateMessage(); |
| 8 | 569 | | var request = message.Request; |
| 8 | 570 | | request.Method = RequestMethod.Get; |
| 8 | 571 | | var uri = new RawRequestUriBuilder(); |
| 8 | 572 | | uri.Reset(endpoint); |
| 8 | 573 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 574 | | uri.AppendPath(subscriptionId, true); |
| 8 | 575 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 576 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 577 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false); |
| 8 | 578 | | uri.AppendPath(virtualNetworkName, true); |
| 8 | 579 | | uri.AppendPath("/CheckIPAddressAvailability", false); |
| 8 | 580 | | uri.AppendQuery("ipAddress", ipAddress, true); |
| 8 | 581 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 8 | 582 | | request.Uri = uri; |
| 8 | 583 | | return message; |
| | 584 | | } |
| | 585 | |
|
| | 586 | | /// <summary> Checks whether a private IP address is available for use. </summary> |
| | 587 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 588 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 589 | | /// <param name="ipAddress"> The private IP address to be verified. </param> |
| | 590 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 591 | | public async Task<Response<IPAddressAvailabilityResult>> CheckIPAddressAvailabilityAsync(string resourceGroupNam |
| | 592 | | { |
| 4 | 593 | | if (resourceGroupName == null) |
| | 594 | | { |
| 0 | 595 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 596 | | } |
| 4 | 597 | | if (virtualNetworkName == null) |
| | 598 | | { |
| 0 | 599 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 600 | | } |
| 4 | 601 | | if (ipAddress == null) |
| | 602 | | { |
| 0 | 603 | | throw new ArgumentNullException(nameof(ipAddress)); |
| | 604 | | } |
| | 605 | |
|
| 4 | 606 | | using var message = CreateCheckIPAddressAvailabilityRequest(resourceGroupName, virtualNetworkName, ipAddress |
| 4 | 607 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 608 | | switch (message.Response.Status) |
| | 609 | | { |
| | 610 | | case 200: |
| | 611 | | { |
| 4 | 612 | | IPAddressAvailabilityResult value = default; |
| 4 | 613 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 614 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 615 | | { |
| 0 | 616 | | value = null; |
| | 617 | | } |
| | 618 | | else |
| | 619 | | { |
| 4 | 620 | | value = IPAddressAvailabilityResult.DeserializeIPAddressAvailabilityResult(document.RootElem |
| | 621 | | } |
| 4 | 622 | | return Response.FromValue(value, message.Response); |
| | 623 | | } |
| | 624 | | default: |
| 0 | 625 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 626 | | } |
| 4 | 627 | | } |
| | 628 | |
|
| | 629 | | /// <summary> Checks whether a private IP address is available for use. </summary> |
| | 630 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 631 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 632 | | /// <param name="ipAddress"> The private IP address to be verified. </param> |
| | 633 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 634 | | public Response<IPAddressAvailabilityResult> CheckIPAddressAvailability(string resourceGroupName, string virtual |
| | 635 | | { |
| 4 | 636 | | if (resourceGroupName == null) |
| | 637 | | { |
| 0 | 638 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 639 | | } |
| 4 | 640 | | if (virtualNetworkName == null) |
| | 641 | | { |
| 0 | 642 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 643 | | } |
| 4 | 644 | | if (ipAddress == null) |
| | 645 | | { |
| 0 | 646 | | throw new ArgumentNullException(nameof(ipAddress)); |
| | 647 | | } |
| | 648 | |
|
| 4 | 649 | | using var message = CreateCheckIPAddressAvailabilityRequest(resourceGroupName, virtualNetworkName, ipAddress |
| 4 | 650 | | _pipeline.Send(message, cancellationToken); |
| 4 | 651 | | switch (message.Response.Status) |
| | 652 | | { |
| | 653 | | case 200: |
| | 654 | | { |
| 4 | 655 | | IPAddressAvailabilityResult value = default; |
| 4 | 656 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 657 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 658 | | { |
| 0 | 659 | | value = null; |
| | 660 | | } |
| | 661 | | else |
| | 662 | | { |
| 4 | 663 | | value = IPAddressAvailabilityResult.DeserializeIPAddressAvailabilityResult(document.RootElem |
| | 664 | | } |
| 4 | 665 | | return Response.FromValue(value, message.Response); |
| | 666 | | } |
| | 667 | | default: |
| 0 | 668 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 669 | | } |
| 4 | 670 | | } |
| | 671 | |
|
| | 672 | | internal HttpMessage CreateListUsageRequest(string resourceGroupName, string virtualNetworkName) |
| | 673 | | { |
| 8 | 674 | | var message = _pipeline.CreateMessage(); |
| 8 | 675 | | var request = message.Request; |
| 8 | 676 | | request.Method = RequestMethod.Get; |
| 8 | 677 | | var uri = new RawRequestUriBuilder(); |
| 8 | 678 | | uri.Reset(endpoint); |
| 8 | 679 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 680 | | uri.AppendPath(subscriptionId, true); |
| 8 | 681 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 682 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 683 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false); |
| 8 | 684 | | uri.AppendPath(virtualNetworkName, true); |
| 8 | 685 | | uri.AppendPath("/usages", false); |
| 8 | 686 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 8 | 687 | | request.Uri = uri; |
| 8 | 688 | | return message; |
| | 689 | | } |
| | 690 | |
|
| | 691 | | /// <summary> Lists usage stats. </summary> |
| | 692 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 693 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 694 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 695 | | public async Task<Response<VirtualNetworkListUsageResult>> ListUsageAsync(string resourceGroupName, string virtu |
| | 696 | | { |
| 4 | 697 | | if (resourceGroupName == null) |
| | 698 | | { |
| 0 | 699 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 700 | | } |
| 4 | 701 | | if (virtualNetworkName == null) |
| | 702 | | { |
| 0 | 703 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 704 | | } |
| | 705 | |
|
| 4 | 706 | | using var message = CreateListUsageRequest(resourceGroupName, virtualNetworkName); |
| 4 | 707 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 708 | | switch (message.Response.Status) |
| | 709 | | { |
| | 710 | | case 200: |
| | 711 | | { |
| 4 | 712 | | VirtualNetworkListUsageResult value = default; |
| 4 | 713 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 714 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 715 | | { |
| 0 | 716 | | value = null; |
| | 717 | | } |
| | 718 | | else |
| | 719 | | { |
| 4 | 720 | | value = VirtualNetworkListUsageResult.DeserializeVirtualNetworkListUsageResult(document.Root |
| | 721 | | } |
| 4 | 722 | | return Response.FromValue(value, message.Response); |
| | 723 | | } |
| | 724 | | default: |
| 0 | 725 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 726 | | } |
| 4 | 727 | | } |
| | 728 | |
|
| | 729 | | /// <summary> Lists usage stats. </summary> |
| | 730 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 731 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 732 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 733 | | public Response<VirtualNetworkListUsageResult> ListUsage(string resourceGroupName, string virtualNetworkName, Ca |
| | 734 | | { |
| 4 | 735 | | if (resourceGroupName == null) |
| | 736 | | { |
| 0 | 737 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 738 | | } |
| 4 | 739 | | if (virtualNetworkName == null) |
| | 740 | | { |
| 0 | 741 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 742 | | } |
| | 743 | |
|
| 4 | 744 | | using var message = CreateListUsageRequest(resourceGroupName, virtualNetworkName); |
| 4 | 745 | | _pipeline.Send(message, cancellationToken); |
| 4 | 746 | | switch (message.Response.Status) |
| | 747 | | { |
| | 748 | | case 200: |
| | 749 | | { |
| 4 | 750 | | VirtualNetworkListUsageResult value = default; |
| 4 | 751 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 752 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 753 | | { |
| 0 | 754 | | value = null; |
| | 755 | | } |
| | 756 | | else |
| | 757 | | { |
| 4 | 758 | | value = VirtualNetworkListUsageResult.DeserializeVirtualNetworkListUsageResult(document.Root |
| | 759 | | } |
| 4 | 760 | | return Response.FromValue(value, message.Response); |
| | 761 | | } |
| | 762 | | default: |
| 0 | 763 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 764 | | } |
| 4 | 765 | | } |
| | 766 | |
|
| | 767 | | internal HttpMessage CreateListAllNextPageRequest(string nextLink) |
| | 768 | | { |
| 0 | 769 | | var message = _pipeline.CreateMessage(); |
| 0 | 770 | | var request = message.Request; |
| 0 | 771 | | request.Method = RequestMethod.Get; |
| 0 | 772 | | var uri = new RawRequestUriBuilder(); |
| 0 | 773 | | uri.Reset(endpoint); |
| 0 | 774 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 775 | | request.Uri = uri; |
| 0 | 776 | | return message; |
| | 777 | | } |
| | 778 | |
|
| | 779 | | /// <summary> Gets all virtual networks in a subscription. </summary> |
| | 780 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 781 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 782 | | public async Task<Response<VirtualNetworkListResult>> ListAllNextPageAsync(string nextLink, CancellationToken ca |
| | 783 | | { |
| 0 | 784 | | if (nextLink == null) |
| | 785 | | { |
| 0 | 786 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 787 | | } |
| | 788 | |
|
| 0 | 789 | | using var message = CreateListAllNextPageRequest(nextLink); |
| 0 | 790 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 791 | | switch (message.Response.Status) |
| | 792 | | { |
| | 793 | | case 200: |
| | 794 | | { |
| 0 | 795 | | VirtualNetworkListResult value = default; |
| 0 | 796 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 797 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 798 | | { |
| 0 | 799 | | value = null; |
| | 800 | | } |
| | 801 | | else |
| | 802 | | { |
| 0 | 803 | | value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement); |
| | 804 | | } |
| 0 | 805 | | return Response.FromValue(value, message.Response); |
| | 806 | | } |
| | 807 | | default: |
| 0 | 808 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 809 | | } |
| 0 | 810 | | } |
| | 811 | |
|
| | 812 | | /// <summary> Gets all virtual networks in a subscription. </summary> |
| | 813 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 814 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 815 | | public Response<VirtualNetworkListResult> ListAllNextPage(string nextLink, CancellationToken cancellationToken = |
| | 816 | | { |
| 0 | 817 | | if (nextLink == null) |
| | 818 | | { |
| 0 | 819 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 820 | | } |
| | 821 | |
|
| 0 | 822 | | using var message = CreateListAllNextPageRequest(nextLink); |
| 0 | 823 | | _pipeline.Send(message, cancellationToken); |
| 0 | 824 | | switch (message.Response.Status) |
| | 825 | | { |
| | 826 | | case 200: |
| | 827 | | { |
| 0 | 828 | | VirtualNetworkListResult value = default; |
| 0 | 829 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 830 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 831 | | { |
| 0 | 832 | | value = null; |
| | 833 | | } |
| | 834 | | else |
| | 835 | | { |
| 0 | 836 | | value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement); |
| | 837 | | } |
| 0 | 838 | | return Response.FromValue(value, message.Response); |
| | 839 | | } |
| | 840 | | default: |
| 0 | 841 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 842 | | } |
| 0 | 843 | | } |
| | 844 | |
|
| | 845 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName) |
| | 846 | | { |
| 0 | 847 | | var message = _pipeline.CreateMessage(); |
| 0 | 848 | | var request = message.Request; |
| 0 | 849 | | request.Method = RequestMethod.Get; |
| 0 | 850 | | var uri = new RawRequestUriBuilder(); |
| 0 | 851 | | uri.Reset(endpoint); |
| 0 | 852 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 853 | | request.Uri = uri; |
| 0 | 854 | | return message; |
| | 855 | | } |
| | 856 | |
|
| | 857 | | /// <summary> Gets all virtual networks in a resource group. </summary> |
| | 858 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 859 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 860 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 861 | | public async Task<Response<VirtualNetworkListResult>> ListNextPageAsync(string nextLink, string resourceGroupNam |
| | 862 | | { |
| 0 | 863 | | if (nextLink == null) |
| | 864 | | { |
| 0 | 865 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 866 | | } |
| 0 | 867 | | if (resourceGroupName == null) |
| | 868 | | { |
| 0 | 869 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 870 | | } |
| | 871 | |
|
| 0 | 872 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName); |
| 0 | 873 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 874 | | switch (message.Response.Status) |
| | 875 | | { |
| | 876 | | case 200: |
| | 877 | | { |
| 0 | 878 | | VirtualNetworkListResult value = default; |
| 0 | 879 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 880 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 881 | | { |
| 0 | 882 | | value = null; |
| | 883 | | } |
| | 884 | | else |
| | 885 | | { |
| 0 | 886 | | value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement); |
| | 887 | | } |
| 0 | 888 | | return Response.FromValue(value, message.Response); |
| | 889 | | } |
| | 890 | | default: |
| 0 | 891 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 892 | | } |
| 0 | 893 | | } |
| | 894 | |
|
| | 895 | | /// <summary> Gets all virtual networks in a resource group. </summary> |
| | 896 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 897 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 898 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 899 | | public Response<VirtualNetworkListResult> ListNextPage(string nextLink, string resourceGroupName, CancellationTo |
| | 900 | | { |
| 0 | 901 | | if (nextLink == null) |
| | 902 | | { |
| 0 | 903 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 904 | | } |
| 0 | 905 | | if (resourceGroupName == null) |
| | 906 | | { |
| 0 | 907 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 908 | | } |
| | 909 | |
|
| 0 | 910 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName); |
| 0 | 911 | | _pipeline.Send(message, cancellationToken); |
| 0 | 912 | | switch (message.Response.Status) |
| | 913 | | { |
| | 914 | | case 200: |
| | 915 | | { |
| 0 | 916 | | VirtualNetworkListResult value = default; |
| 0 | 917 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 918 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 919 | | { |
| 0 | 920 | | value = null; |
| | 921 | | } |
| | 922 | | else |
| | 923 | | { |
| 0 | 924 | | value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement); |
| | 925 | | } |
| 0 | 926 | | return Response.FromValue(value, message.Response); |
| | 927 | | } |
| | 928 | | default: |
| 0 | 929 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 930 | | } |
| 0 | 931 | | } |
| | 932 | |
|
| | 933 | | internal HttpMessage CreateListUsageNextPageRequest(string nextLink, string resourceGroupName, string virtualNet |
| | 934 | | { |
| 0 | 935 | | var message = _pipeline.CreateMessage(); |
| 0 | 936 | | var request = message.Request; |
| 0 | 937 | | request.Method = RequestMethod.Get; |
| 0 | 938 | | var uri = new RawRequestUriBuilder(); |
| 0 | 939 | | uri.Reset(endpoint); |
| 0 | 940 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 941 | | request.Uri = uri; |
| 0 | 942 | | return message; |
| | 943 | | } |
| | 944 | |
|
| | 945 | | /// <summary> Lists usage stats. </summary> |
| | 946 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 947 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 948 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 949 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 950 | | public async Task<Response<VirtualNetworkListUsageResult>> ListUsageNextPageAsync(string nextLink, string resour |
| | 951 | | { |
| 0 | 952 | | if (nextLink == null) |
| | 953 | | { |
| 0 | 954 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 955 | | } |
| 0 | 956 | | if (resourceGroupName == null) |
| | 957 | | { |
| 0 | 958 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 959 | | } |
| 0 | 960 | | if (virtualNetworkName == null) |
| | 961 | | { |
| 0 | 962 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 963 | | } |
| | 964 | |
|
| 0 | 965 | | using var message = CreateListUsageNextPageRequest(nextLink, resourceGroupName, virtualNetworkName); |
| 0 | 966 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 967 | | switch (message.Response.Status) |
| | 968 | | { |
| | 969 | | case 200: |
| | 970 | | { |
| 0 | 971 | | VirtualNetworkListUsageResult value = default; |
| 0 | 972 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 973 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 974 | | { |
| 0 | 975 | | value = null; |
| | 976 | | } |
| | 977 | | else |
| | 978 | | { |
| 0 | 979 | | value = VirtualNetworkListUsageResult.DeserializeVirtualNetworkListUsageResult(document.Root |
| | 980 | | } |
| 0 | 981 | | return Response.FromValue(value, message.Response); |
| | 982 | | } |
| | 983 | | default: |
| 0 | 984 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 985 | | } |
| 0 | 986 | | } |
| | 987 | |
|
| | 988 | | /// <summary> Lists usage stats. </summary> |
| | 989 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 990 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 991 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 992 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 993 | | public Response<VirtualNetworkListUsageResult> ListUsageNextPage(string nextLink, string resourceGroupName, stri |
| | 994 | | { |
| 0 | 995 | | if (nextLink == null) |
| | 996 | | { |
| 0 | 997 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 998 | | } |
| 0 | 999 | | if (resourceGroupName == null) |
| | 1000 | | { |
| 0 | 1001 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1002 | | } |
| 0 | 1003 | | if (virtualNetworkName == null) |
| | 1004 | | { |
| 0 | 1005 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 1006 | | } |
| | 1007 | |
|
| 0 | 1008 | | using var message = CreateListUsageNextPageRequest(nextLink, resourceGroupName, virtualNetworkName); |
| 0 | 1009 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1010 | | switch (message.Response.Status) |
| | 1011 | | { |
| | 1012 | | case 200: |
| | 1013 | | { |
| 0 | 1014 | | VirtualNetworkListUsageResult value = default; |
| 0 | 1015 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1016 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1017 | | { |
| 0 | 1018 | | value = null; |
| | 1019 | | } |
| | 1020 | | else |
| | 1021 | | { |
| 0 | 1022 | | value = VirtualNetworkListUsageResult.DeserializeVirtualNetworkListUsageResult(document.Root |
| | 1023 | | } |
| 0 | 1024 | | return Response.FromValue(value, message.Response); |
| | 1025 | | } |
| | 1026 | | default: |
| 0 | 1027 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1028 | | } |
| 0 | 1029 | | } |
| | 1030 | | } |
| | 1031 | | } |