| | 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.Threading; |
| | 10 | | using System.Threading.Tasks; |
| | 11 | | using Azure; |
| | 12 | | using Azure.Core; |
| | 13 | | using Azure.Core.Pipeline; |
| | 14 | | using Azure.ResourceManager.Network.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.Network |
| | 17 | | { |
| | 18 | | /// <summary> The NetworkInterfaceLoadBalancers service client. </summary> |
| | 19 | | public partial class NetworkInterfaceLoadBalancersOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 4 | 23 | | internal NetworkInterfaceLoadBalancersRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of NetworkInterfaceLoadBalancersOperations for mocking. </summary> |
| 4 | 25 | | protected NetworkInterfaceLoadBalancersOperations() |
| | 26 | | { |
| 4 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of NetworkInterfaceLoadBalancersOperations. </summary> |
| | 29 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 30 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 31 | | /// <param name="subscriptionId"> The subscription credentials which uniquely identify the Microsoft Azure subsc |
| | 32 | | /// <param name="endpoint"> server parameter. </param> |
| 4 | 33 | | internal NetworkInterfaceLoadBalancersOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, str |
| | 34 | | { |
| 4 | 35 | | RestClient = new NetworkInterfaceLoadBalancersRestOperations(clientDiagnostics, pipeline, subscriptionId, en |
| 4 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 4 | 37 | | _pipeline = pipeline; |
| 4 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> List all load balancers in a network interface. </summary> |
| | 41 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 42 | | /// <param name="networkInterfaceName"> The name of the network interface. </param> |
| | 43 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 44 | | public virtual AsyncPageable<LoadBalancer> ListAsync(string resourceGroupName, string networkInterfaceName, Canc |
| | 45 | | { |
| 2 | 46 | | if (resourceGroupName == null) |
| | 47 | | { |
| 0 | 48 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 49 | | } |
| 2 | 50 | | if (networkInterfaceName == null) |
| | 51 | | { |
| 0 | 52 | | throw new ArgumentNullException(nameof(networkInterfaceName)); |
| | 53 | | } |
| | 54 | |
|
| | 55 | | async Task<Page<LoadBalancer>> FirstPageFunc(int? pageSizeHint) |
| | 56 | | { |
| 2 | 57 | | using var scope = _clientDiagnostics.CreateScope("NetworkInterfaceLoadBalancersOperations.List"); |
| 2 | 58 | | scope.Start(); |
| | 59 | | try |
| | 60 | | { |
| 2 | 61 | | var response = await RestClient.ListAsync(resourceGroupName, networkInterfaceName, cancellationToken |
| 2 | 62 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 63 | | } |
| 0 | 64 | | catch (Exception e) |
| | 65 | | { |
| 0 | 66 | | scope.Failed(e); |
| 0 | 67 | | throw; |
| | 68 | | } |
| 2 | 69 | | } |
| | 70 | | async Task<Page<LoadBalancer>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 71 | | { |
| 0 | 72 | | using var scope = _clientDiagnostics.CreateScope("NetworkInterfaceLoadBalancersOperations.List"); |
| 0 | 73 | | scope.Start(); |
| | 74 | | try |
| | 75 | | { |
| 0 | 76 | | var response = await RestClient.ListNextPageAsync(nextLink, resourceGroupName, networkInterfaceName, |
| 0 | 77 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 78 | | } |
| 0 | 79 | | catch (Exception e) |
| | 80 | | { |
| 0 | 81 | | scope.Failed(e); |
| 0 | 82 | | throw; |
| | 83 | | } |
| 0 | 84 | | } |
| 2 | 85 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 86 | | } |
| | 87 | |
|
| | 88 | | /// <summary> List all load balancers in a network interface. </summary> |
| | 89 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 90 | | /// <param name="networkInterfaceName"> The name of the network interface. </param> |
| | 91 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 92 | | public virtual Pageable<LoadBalancer> List(string resourceGroupName, string networkInterfaceName, CancellationTo |
| | 93 | | { |
| 2 | 94 | | if (resourceGroupName == null) |
| | 95 | | { |
| 0 | 96 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 97 | | } |
| 2 | 98 | | if (networkInterfaceName == null) |
| | 99 | | { |
| 0 | 100 | | throw new ArgumentNullException(nameof(networkInterfaceName)); |
| | 101 | | } |
| | 102 | |
|
| | 103 | | Page<LoadBalancer> FirstPageFunc(int? pageSizeHint) |
| | 104 | | { |
| 2 | 105 | | using var scope = _clientDiagnostics.CreateScope("NetworkInterfaceLoadBalancersOperations.List"); |
| 2 | 106 | | scope.Start(); |
| | 107 | | try |
| | 108 | | { |
| 2 | 109 | | var response = RestClient.List(resourceGroupName, networkInterfaceName, cancellationToken); |
| 2 | 110 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 111 | | } |
| 0 | 112 | | catch (Exception e) |
| | 113 | | { |
| 0 | 114 | | scope.Failed(e); |
| 0 | 115 | | throw; |
| | 116 | | } |
| 2 | 117 | | } |
| | 118 | | Page<LoadBalancer> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 119 | | { |
| 0 | 120 | | using var scope = _clientDiagnostics.CreateScope("NetworkInterfaceLoadBalancersOperations.List"); |
| 0 | 121 | | scope.Start(); |
| | 122 | | try |
| | 123 | | { |
| 0 | 124 | | var response = RestClient.ListNextPage(nextLink, resourceGroupName, networkInterfaceName, cancellati |
| 0 | 125 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 126 | | } |
| 0 | 127 | | catch (Exception e) |
| | 128 | | { |
| 0 | 129 | | scope.Failed(e); |
| 0 | 130 | | throw; |
| | 131 | | } |
| 0 | 132 | | } |
| 2 | 133 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 134 | | } |
| | 135 | | } |
| | 136 | | } |