| | 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 NetworkInterfaceLoadBalancersRestOperations |
| | 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 NetworkInterfaceLoadBalancersRestOperations. </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 |
| 4 | 32 | | public NetworkInterfaceLoadBalancersRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, s |
| | 33 | | { |
| 4 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 4 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 4 | 40 | | this.subscriptionId = subscriptionId; |
| 4 | 41 | | this.endpoint = endpoint; |
| 4 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 4 | 43 | | _pipeline = pipeline; |
| 4 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateListRequest(string resourceGroupName, string networkInterfaceName) |
| | 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("/resourceGroups/", false); |
| 4 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 57 | | uri.AppendPath("/providers/Microsoft.Network/networkInterfaces/", false); |
| 4 | 58 | | uri.AppendPath(networkInterfaceName, true); |
| 4 | 59 | | uri.AppendPath("/loadBalancers", false); |
| 4 | 60 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 4 | 61 | | request.Uri = uri; |
| 4 | 62 | | return message; |
| | 63 | | } |
| | 64 | |
|
| | 65 | | /// <summary> List all load balancers in a network interface. </summary> |
| | 66 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 67 | | /// <param name="networkInterfaceName"> The name of the network interface. </param> |
| | 68 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 69 | | public async Task<Response<NetworkInterfaceLoadBalancerListResult>> ListAsync(string resourceGroupName, string n |
| | 70 | | { |
| 2 | 71 | | if (resourceGroupName == null) |
| | 72 | | { |
| 0 | 73 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 74 | | } |
| 2 | 75 | | if (networkInterfaceName == null) |
| | 76 | | { |
| 0 | 77 | | throw new ArgumentNullException(nameof(networkInterfaceName)); |
| | 78 | | } |
| | 79 | |
|
| 2 | 80 | | using var message = CreateListRequest(resourceGroupName, networkInterfaceName); |
| 2 | 81 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 82 | | switch (message.Response.Status) |
| | 83 | | { |
| | 84 | | case 200: |
| | 85 | | { |
| 2 | 86 | | NetworkInterfaceLoadBalancerListResult value = default; |
| 2 | 87 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 88 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 89 | | { |
| 0 | 90 | | value = null; |
| | 91 | | } |
| | 92 | | else |
| | 93 | | { |
| 2 | 94 | | value = NetworkInterfaceLoadBalancerListResult.DeserializeNetworkInterfaceLoadBalancerListRe |
| | 95 | | } |
| 2 | 96 | | return Response.FromValue(value, message.Response); |
| | 97 | | } |
| | 98 | | default: |
| 0 | 99 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 100 | | } |
| 2 | 101 | | } |
| | 102 | |
|
| | 103 | | /// <summary> List all load balancers in a network interface. </summary> |
| | 104 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 105 | | /// <param name="networkInterfaceName"> The name of the network interface. </param> |
| | 106 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 107 | | public Response<NetworkInterfaceLoadBalancerListResult> List(string resourceGroupName, string networkInterfaceNa |
| | 108 | | { |
| 2 | 109 | | if (resourceGroupName == null) |
| | 110 | | { |
| 0 | 111 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 112 | | } |
| 2 | 113 | | if (networkInterfaceName == null) |
| | 114 | | { |
| 0 | 115 | | throw new ArgumentNullException(nameof(networkInterfaceName)); |
| | 116 | | } |
| | 117 | |
|
| 2 | 118 | | using var message = CreateListRequest(resourceGroupName, networkInterfaceName); |
| 2 | 119 | | _pipeline.Send(message, cancellationToken); |
| 2 | 120 | | switch (message.Response.Status) |
| | 121 | | { |
| | 122 | | case 200: |
| | 123 | | { |
| 2 | 124 | | NetworkInterfaceLoadBalancerListResult value = default; |
| 2 | 125 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 126 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 127 | | { |
| 0 | 128 | | value = null; |
| | 129 | | } |
| | 130 | | else |
| | 131 | | { |
| 2 | 132 | | value = NetworkInterfaceLoadBalancerListResult.DeserializeNetworkInterfaceLoadBalancerListRe |
| | 133 | | } |
| 2 | 134 | | return Response.FromValue(value, message.Response); |
| | 135 | | } |
| | 136 | | default: |
| 0 | 137 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 138 | | } |
| 2 | 139 | | } |
| | 140 | |
|
| | 141 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string networkInterfac |
| | 142 | | { |
| 0 | 143 | | var message = _pipeline.CreateMessage(); |
| 0 | 144 | | var request = message.Request; |
| 0 | 145 | | request.Method = RequestMethod.Get; |
| 0 | 146 | | var uri = new RawRequestUriBuilder(); |
| 0 | 147 | | uri.Reset(endpoint); |
| 0 | 148 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 149 | | request.Uri = uri; |
| 0 | 150 | | return message; |
| | 151 | | } |
| | 152 | |
|
| | 153 | | /// <summary> List all load balancers in a network interface. </summary> |
| | 154 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 155 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 156 | | /// <param name="networkInterfaceName"> The name of the network interface. </param> |
| | 157 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 158 | | public async Task<Response<NetworkInterfaceLoadBalancerListResult>> ListNextPageAsync(string nextLink, string re |
| | 159 | | { |
| 0 | 160 | | if (nextLink == null) |
| | 161 | | { |
| 0 | 162 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 163 | | } |
| 0 | 164 | | if (resourceGroupName == null) |
| | 165 | | { |
| 0 | 166 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 167 | | } |
| 0 | 168 | | if (networkInterfaceName == null) |
| | 169 | | { |
| 0 | 170 | | throw new ArgumentNullException(nameof(networkInterfaceName)); |
| | 171 | | } |
| | 172 | |
|
| 0 | 173 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, networkInterfaceName); |
| 0 | 174 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 175 | | switch (message.Response.Status) |
| | 176 | | { |
| | 177 | | case 200: |
| | 178 | | { |
| 0 | 179 | | NetworkInterfaceLoadBalancerListResult value = default; |
| 0 | 180 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 181 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 182 | | { |
| 0 | 183 | | value = null; |
| | 184 | | } |
| | 185 | | else |
| | 186 | | { |
| 0 | 187 | | value = NetworkInterfaceLoadBalancerListResult.DeserializeNetworkInterfaceLoadBalancerListRe |
| | 188 | | } |
| 0 | 189 | | return Response.FromValue(value, message.Response); |
| | 190 | | } |
| | 191 | | default: |
| 0 | 192 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 193 | | } |
| 0 | 194 | | } |
| | 195 | |
|
| | 196 | | /// <summary> List all load balancers in a network interface. </summary> |
| | 197 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 198 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 199 | | /// <param name="networkInterfaceName"> The name of the network interface. </param> |
| | 200 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 201 | | public Response<NetworkInterfaceLoadBalancerListResult> ListNextPage(string nextLink, string resourceGroupName, |
| | 202 | | { |
| 0 | 203 | | if (nextLink == null) |
| | 204 | | { |
| 0 | 205 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 206 | | } |
| 0 | 207 | | if (resourceGroupName == null) |
| | 208 | | { |
| 0 | 209 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 210 | | } |
| 0 | 211 | | if (networkInterfaceName == null) |
| | 212 | | { |
| 0 | 213 | | throw new ArgumentNullException(nameof(networkInterfaceName)); |
| | 214 | | } |
| | 215 | |
|
| 0 | 216 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, networkInterfaceName); |
| 0 | 217 | | _pipeline.Send(message, cancellationToken); |
| 0 | 218 | | switch (message.Response.Status) |
| | 219 | | { |
| | 220 | | case 200: |
| | 221 | | { |
| 0 | 222 | | NetworkInterfaceLoadBalancerListResult value = default; |
| 0 | 223 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 224 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 225 | | { |
| 0 | 226 | | value = null; |
| | 227 | | } |
| | 228 | | else |
| | 229 | | { |
| 0 | 230 | | value = NetworkInterfaceLoadBalancerListResult.DeserializeNetworkInterfaceLoadBalancerListRe |
| | 231 | | } |
| 0 | 232 | | return Response.FromValue(value, message.Response); |
| | 233 | | } |
| | 234 | | default: |
| 0 | 235 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 236 | | } |
| 0 | 237 | | } |
| | 238 | | } |
| | 239 | | } |