| | 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 LoadBalancerNetworkInterfacesRestOperations |
| | 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 LoadBalancerNetworkInterfacesRestOperations. </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 |
| 8 | 32 | | public LoadBalancerNetworkInterfacesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, s |
| | 33 | | { |
| 8 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 8 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 8 | 40 | | this.subscriptionId = subscriptionId; |
| 8 | 41 | | this.endpoint = endpoint; |
| 8 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 8 | 43 | | _pipeline = pipeline; |
| 8 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateListRequest(string resourceGroupName, string loadBalancerName) |
| | 47 | | { |
| 8 | 48 | | var message = _pipeline.CreateMessage(); |
| 8 | 49 | | var request = message.Request; |
| 8 | 50 | | request.Method = RequestMethod.Get; |
| 8 | 51 | | var uri = new RawRequestUriBuilder(); |
| 8 | 52 | | uri.Reset(endpoint); |
| 8 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 54 | | uri.AppendPath(subscriptionId, true); |
| 8 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 57 | | uri.AppendPath("/providers/Microsoft.Network/loadBalancers/", false); |
| 8 | 58 | | uri.AppendPath(loadBalancerName, true); |
| 8 | 59 | | uri.AppendPath("/networkInterfaces", false); |
| 8 | 60 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 8 | 61 | | request.Uri = uri; |
| 8 | 62 | | return message; |
| | 63 | | } |
| | 64 | |
|
| | 65 | | /// <summary> Gets associated load balancer network interfaces. </summary> |
| | 66 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 67 | | /// <param name="loadBalancerName"> The name of the load balancer. </param> |
| | 68 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 69 | | public async Task<Response<NetworkInterfaceListResult>> ListAsync(string resourceGroupName, string loadBalancerN |
| | 70 | | { |
| 4 | 71 | | if (resourceGroupName == null) |
| | 72 | | { |
| 0 | 73 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 74 | | } |
| 4 | 75 | | if (loadBalancerName == null) |
| | 76 | | { |
| 0 | 77 | | throw new ArgumentNullException(nameof(loadBalancerName)); |
| | 78 | | } |
| | 79 | |
|
| 4 | 80 | | using var message = CreateListRequest(resourceGroupName, loadBalancerName); |
| 4 | 81 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 82 | | switch (message.Response.Status) |
| | 83 | | { |
| | 84 | | case 200: |
| | 85 | | { |
| 4 | 86 | | NetworkInterfaceListResult value = default; |
| 4 | 87 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 88 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 89 | | { |
| 0 | 90 | | value = null; |
| | 91 | | } |
| | 92 | | else |
| | 93 | | { |
| 4 | 94 | | value = NetworkInterfaceListResult.DeserializeNetworkInterfaceListResult(document.RootElemen |
| | 95 | | } |
| 4 | 96 | | return Response.FromValue(value, message.Response); |
| | 97 | | } |
| | 98 | | default: |
| 0 | 99 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 100 | | } |
| 4 | 101 | | } |
| | 102 | |
|
| | 103 | | /// <summary> Gets associated load balancer network interfaces. </summary> |
| | 104 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 105 | | /// <param name="loadBalancerName"> The name of the load balancer. </param> |
| | 106 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 107 | | public Response<NetworkInterfaceListResult> List(string resourceGroupName, string loadBalancerName, Cancellation |
| | 108 | | { |
| 4 | 109 | | if (resourceGroupName == null) |
| | 110 | | { |
| 0 | 111 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 112 | | } |
| 4 | 113 | | if (loadBalancerName == null) |
| | 114 | | { |
| 0 | 115 | | throw new ArgumentNullException(nameof(loadBalancerName)); |
| | 116 | | } |
| | 117 | |
|
| 4 | 118 | | using var message = CreateListRequest(resourceGroupName, loadBalancerName); |
| 4 | 119 | | _pipeline.Send(message, cancellationToken); |
| 4 | 120 | | switch (message.Response.Status) |
| | 121 | | { |
| | 122 | | case 200: |
| | 123 | | { |
| 4 | 124 | | NetworkInterfaceListResult value = default; |
| 4 | 125 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 126 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 127 | | { |
| 0 | 128 | | value = null; |
| | 129 | | } |
| | 130 | | else |
| | 131 | | { |
| 4 | 132 | | value = NetworkInterfaceListResult.DeserializeNetworkInterfaceListResult(document.RootElemen |
| | 133 | | } |
| 4 | 134 | | return Response.FromValue(value, message.Response); |
| | 135 | | } |
| | 136 | | default: |
| 0 | 137 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 138 | | } |
| 4 | 139 | | } |
| | 140 | |
|
| | 141 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string loadBalancerNam |
| | 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> Gets associated load balancer network interfaces. </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="loadBalancerName"> The name of the load balancer. </param> |
| | 157 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 158 | | public async Task<Response<NetworkInterfaceListResult>> ListNextPageAsync(string nextLink, string resourceGroupN |
| | 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 (loadBalancerName == null) |
| | 169 | | { |
| 0 | 170 | | throw new ArgumentNullException(nameof(loadBalancerName)); |
| | 171 | | } |
| | 172 | |
|
| 0 | 173 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, loadBalancerName); |
| 0 | 174 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 175 | | switch (message.Response.Status) |
| | 176 | | { |
| | 177 | | case 200: |
| | 178 | | { |
| 0 | 179 | | NetworkInterfaceListResult 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 = NetworkInterfaceListResult.DeserializeNetworkInterfaceListResult(document.RootElemen |
| | 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> Gets associated load balancer network interfaces. </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="loadBalancerName"> The name of the load balancer. </param> |
| | 200 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 201 | | public Response<NetworkInterfaceListResult> ListNextPage(string nextLink, string resourceGroupName, string loadB |
| | 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 (loadBalancerName == null) |
| | 212 | | { |
| 0 | 213 | | throw new ArgumentNullException(nameof(loadBalancerName)); |
| | 214 | | } |
| | 215 | |
|
| 0 | 216 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, loadBalancerName); |
| 0 | 217 | | _pipeline.Send(message, cancellationToken); |
| 0 | 218 | | switch (message.Response.Status) |
| | 219 | | { |
| | 220 | | case 200: |
| | 221 | | { |
| 0 | 222 | | NetworkInterfaceListResult 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 = NetworkInterfaceListResult.DeserializeNetworkInterfaceListResult(document.RootElemen |
| | 231 | | } |
| 0 | 232 | | return Response.FromValue(value, message.Response); |
| | 233 | | } |
| | 234 | | default: |
| 0 | 235 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 236 | | } |
| 0 | 237 | | } |
| | 238 | | } |
| | 239 | | } |