| | 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 NetworkInterfaceIPConfigurationsRestOperations |
| | 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 NetworkInterfaceIPConfigurationsRestOperations. </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 NetworkInterfaceIPConfigurationsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline |
| | 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 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("/ipConfigurations", false); |
| 4 | 60 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 4 | 61 | | request.Uri = uri; |
| 4 | 62 | | return message; |
| | 63 | | } |
| | 64 | |
|
| | 65 | | /// <summary> Get all ip configurations 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<NetworkInterfaceIPConfigurationListResult>> ListAsync(string resourceGroupName, strin |
| | 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 | | NetworkInterfaceIPConfigurationListResult 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 = NetworkInterfaceIPConfigurationListResult.DeserializeNetworkInterfaceIPConfiguration |
| | 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> Get all ip configurations 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<NetworkInterfaceIPConfigurationListResult> List(string resourceGroupName, string networkInterfac |
| | 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 | | NetworkInterfaceIPConfigurationListResult 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 = NetworkInterfaceIPConfigurationListResult.DeserializeNetworkInterfaceIPConfiguration |
| | 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 CreateGetRequest(string resourceGroupName, string networkInterfaceName, string ipConfigurat |
| | 142 | | { |
| 4 | 143 | | var message = _pipeline.CreateMessage(); |
| 4 | 144 | | var request = message.Request; |
| 4 | 145 | | request.Method = RequestMethod.Get; |
| 4 | 146 | | var uri = new RawRequestUriBuilder(); |
| 4 | 147 | | uri.Reset(endpoint); |
| 4 | 148 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 149 | | uri.AppendPath(subscriptionId, true); |
| 4 | 150 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 151 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 152 | | uri.AppendPath("/providers/Microsoft.Network/networkInterfaces/", false); |
| 4 | 153 | | uri.AppendPath(networkInterfaceName, true); |
| 4 | 154 | | uri.AppendPath("/ipConfigurations/", false); |
| 4 | 155 | | uri.AppendPath(ipConfigurationName, true); |
| 4 | 156 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 4 | 157 | | request.Uri = uri; |
| 4 | 158 | | return message; |
| | 159 | | } |
| | 160 | |
|
| | 161 | | /// <summary> Gets the specified network interface ip configuration. </summary> |
| | 162 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 163 | | /// <param name="networkInterfaceName"> The name of the network interface. </param> |
| | 164 | | /// <param name="ipConfigurationName"> The name of the ip configuration name. </param> |
| | 165 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 166 | | public async Task<Response<NetworkInterfaceIPConfiguration>> GetAsync(string resourceGroupName, string networkIn |
| | 167 | | { |
| 2 | 168 | | if (resourceGroupName == null) |
| | 169 | | { |
| 0 | 170 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 171 | | } |
| 2 | 172 | | if (networkInterfaceName == null) |
| | 173 | | { |
| 0 | 174 | | throw new ArgumentNullException(nameof(networkInterfaceName)); |
| | 175 | | } |
| 2 | 176 | | if (ipConfigurationName == null) |
| | 177 | | { |
| 0 | 178 | | throw new ArgumentNullException(nameof(ipConfigurationName)); |
| | 179 | | } |
| | 180 | |
|
| 2 | 181 | | using var message = CreateGetRequest(resourceGroupName, networkInterfaceName, ipConfigurationName); |
| 2 | 182 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 183 | | switch (message.Response.Status) |
| | 184 | | { |
| | 185 | | case 200: |
| | 186 | | { |
| 2 | 187 | | NetworkInterfaceIPConfiguration value = default; |
| 2 | 188 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 189 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 190 | | { |
| 0 | 191 | | value = null; |
| | 192 | | } |
| | 193 | | else |
| | 194 | | { |
| 2 | 195 | | value = NetworkInterfaceIPConfiguration.DeserializeNetworkInterfaceIPConfiguration(document. |
| | 196 | | } |
| 2 | 197 | | return Response.FromValue(value, message.Response); |
| | 198 | | } |
| | 199 | | default: |
| 0 | 200 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 201 | | } |
| 2 | 202 | | } |
| | 203 | |
|
| | 204 | | /// <summary> Gets the specified network interface ip configuration. </summary> |
| | 205 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 206 | | /// <param name="networkInterfaceName"> The name of the network interface. </param> |
| | 207 | | /// <param name="ipConfigurationName"> The name of the ip configuration name. </param> |
| | 208 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 209 | | public Response<NetworkInterfaceIPConfiguration> Get(string resourceGroupName, string networkInterfaceName, stri |
| | 210 | | { |
| 2 | 211 | | if (resourceGroupName == null) |
| | 212 | | { |
| 0 | 213 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 214 | | } |
| 2 | 215 | | if (networkInterfaceName == null) |
| | 216 | | { |
| 0 | 217 | | throw new ArgumentNullException(nameof(networkInterfaceName)); |
| | 218 | | } |
| 2 | 219 | | if (ipConfigurationName == null) |
| | 220 | | { |
| 0 | 221 | | throw new ArgumentNullException(nameof(ipConfigurationName)); |
| | 222 | | } |
| | 223 | |
|
| 2 | 224 | | using var message = CreateGetRequest(resourceGroupName, networkInterfaceName, ipConfigurationName); |
| 2 | 225 | | _pipeline.Send(message, cancellationToken); |
| 2 | 226 | | switch (message.Response.Status) |
| | 227 | | { |
| | 228 | | case 200: |
| | 229 | | { |
| 2 | 230 | | NetworkInterfaceIPConfiguration value = default; |
| 2 | 231 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 232 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 233 | | { |
| 0 | 234 | | value = null; |
| | 235 | | } |
| | 236 | | else |
| | 237 | | { |
| 2 | 238 | | value = NetworkInterfaceIPConfiguration.DeserializeNetworkInterfaceIPConfiguration(document. |
| | 239 | | } |
| 2 | 240 | | return Response.FromValue(value, message.Response); |
| | 241 | | } |
| | 242 | | default: |
| 0 | 243 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 244 | | } |
| 2 | 245 | | } |
| | 246 | |
|
| | 247 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string networkInterfac |
| | 248 | | { |
| 0 | 249 | | var message = _pipeline.CreateMessage(); |
| 0 | 250 | | var request = message.Request; |
| 0 | 251 | | request.Method = RequestMethod.Get; |
| 0 | 252 | | var uri = new RawRequestUriBuilder(); |
| 0 | 253 | | uri.Reset(endpoint); |
| 0 | 254 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 255 | | request.Uri = uri; |
| 0 | 256 | | return message; |
| | 257 | | } |
| | 258 | |
|
| | 259 | | /// <summary> Get all ip configurations in a network interface. </summary> |
| | 260 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 261 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 262 | | /// <param name="networkInterfaceName"> The name of the network interface. </param> |
| | 263 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 264 | | public async Task<Response<NetworkInterfaceIPConfigurationListResult>> ListNextPageAsync(string nextLink, string |
| | 265 | | { |
| 0 | 266 | | if (nextLink == null) |
| | 267 | | { |
| 0 | 268 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 269 | | } |
| 0 | 270 | | if (resourceGroupName == null) |
| | 271 | | { |
| 0 | 272 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 273 | | } |
| 0 | 274 | | if (networkInterfaceName == null) |
| | 275 | | { |
| 0 | 276 | | throw new ArgumentNullException(nameof(networkInterfaceName)); |
| | 277 | | } |
| | 278 | |
|
| 0 | 279 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, networkInterfaceName); |
| 0 | 280 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 281 | | switch (message.Response.Status) |
| | 282 | | { |
| | 283 | | case 200: |
| | 284 | | { |
| 0 | 285 | | NetworkInterfaceIPConfigurationListResult value = default; |
| 0 | 286 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 287 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 288 | | { |
| 0 | 289 | | value = null; |
| | 290 | | } |
| | 291 | | else |
| | 292 | | { |
| 0 | 293 | | value = NetworkInterfaceIPConfigurationListResult.DeserializeNetworkInterfaceIPConfiguration |
| | 294 | | } |
| 0 | 295 | | return Response.FromValue(value, message.Response); |
| | 296 | | } |
| | 297 | | default: |
| 0 | 298 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 299 | | } |
| 0 | 300 | | } |
| | 301 | |
|
| | 302 | | /// <summary> Get all ip configurations in a network interface. </summary> |
| | 303 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 304 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 305 | | /// <param name="networkInterfaceName"> The name of the network interface. </param> |
| | 306 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 307 | | public Response<NetworkInterfaceIPConfigurationListResult> ListNextPage(string nextLink, string resourceGroupNam |
| | 308 | | { |
| 0 | 309 | | if (nextLink == null) |
| | 310 | | { |
| 0 | 311 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 312 | | } |
| 0 | 313 | | if (resourceGroupName == null) |
| | 314 | | { |
| 0 | 315 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 316 | | } |
| 0 | 317 | | if (networkInterfaceName == null) |
| | 318 | | { |
| 0 | 319 | | throw new ArgumentNullException(nameof(networkInterfaceName)); |
| | 320 | | } |
| | 321 | |
|
| 0 | 322 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, networkInterfaceName); |
| 0 | 323 | | _pipeline.Send(message, cancellationToken); |
| 0 | 324 | | switch (message.Response.Status) |
| | 325 | | { |
| | 326 | | case 200: |
| | 327 | | { |
| 0 | 328 | | NetworkInterfaceIPConfigurationListResult value = default; |
| 0 | 329 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 330 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 331 | | { |
| 0 | 332 | | value = null; |
| | 333 | | } |
| | 334 | | else |
| | 335 | | { |
| 0 | 336 | | value = NetworkInterfaceIPConfigurationListResult.DeserializeNetworkInterfaceIPConfiguration |
| | 337 | | } |
| 0 | 338 | | return Response.FromValue(value, message.Response); |
| | 339 | | } |
| | 340 | | default: |
| 0 | 341 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 342 | | } |
| 0 | 343 | | } |
| | 344 | | } |
| | 345 | | } |