| | 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 ExpressRouteLinksRestOperations |
| | 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 ExpressRouteLinksRestOperations. </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 |
| 0 | 32 | | public ExpressRouteLinksRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscr |
| | 33 | | { |
| 0 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 0 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 0 | 40 | | this.subscriptionId = subscriptionId; |
| 0 | 41 | | this.endpoint = endpoint; |
| 0 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 43 | | _pipeline = pipeline; |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string expressRoutePortName, string linkName) |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Get; |
| 0 | 51 | | var uri = new RawRequestUriBuilder(); |
| 0 | 52 | | uri.Reset(endpoint); |
| 0 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 54 | | uri.AppendPath(subscriptionId, true); |
| 0 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 57 | | uri.AppendPath("/providers/Microsoft.Network/ExpressRoutePorts/", false); |
| 0 | 58 | | uri.AppendPath(expressRoutePortName, true); |
| 0 | 59 | | uri.AppendPath("/links/", false); |
| 0 | 60 | | uri.AppendPath(linkName, true); |
| 0 | 61 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 62 | | request.Uri = uri; |
| 0 | 63 | | return message; |
| | 64 | | } |
| | 65 | |
|
| | 66 | | /// <summary> Retrieves the specified ExpressRouteLink resource. </summary> |
| | 67 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 68 | | /// <param name="expressRoutePortName"> The name of the ExpressRoutePort resource. </param> |
| | 69 | | /// <param name="linkName"> The name of the ExpressRouteLink resource. </param> |
| | 70 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 71 | | public async Task<Response<ExpressRouteLink>> GetAsync(string resourceGroupName, string expressRoutePortName, st |
| | 72 | | { |
| 0 | 73 | | if (resourceGroupName == null) |
| | 74 | | { |
| 0 | 75 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 76 | | } |
| 0 | 77 | | if (expressRoutePortName == null) |
| | 78 | | { |
| 0 | 79 | | throw new ArgumentNullException(nameof(expressRoutePortName)); |
| | 80 | | } |
| 0 | 81 | | if (linkName == null) |
| | 82 | | { |
| 0 | 83 | | throw new ArgumentNullException(nameof(linkName)); |
| | 84 | | } |
| | 85 | |
|
| 0 | 86 | | using var message = CreateGetRequest(resourceGroupName, expressRoutePortName, linkName); |
| 0 | 87 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 88 | | switch (message.Response.Status) |
| | 89 | | { |
| | 90 | | case 200: |
| | 91 | | { |
| 0 | 92 | | ExpressRouteLink value = default; |
| 0 | 93 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 94 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 95 | | { |
| 0 | 96 | | value = null; |
| | 97 | | } |
| | 98 | | else |
| | 99 | | { |
| 0 | 100 | | value = ExpressRouteLink.DeserializeExpressRouteLink(document.RootElement); |
| | 101 | | } |
| 0 | 102 | | return Response.FromValue(value, message.Response); |
| | 103 | | } |
| | 104 | | default: |
| 0 | 105 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 106 | | } |
| 0 | 107 | | } |
| | 108 | |
|
| | 109 | | /// <summary> Retrieves the specified ExpressRouteLink resource. </summary> |
| | 110 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 111 | | /// <param name="expressRoutePortName"> The name of the ExpressRoutePort resource. </param> |
| | 112 | | /// <param name="linkName"> The name of the ExpressRouteLink resource. </param> |
| | 113 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 114 | | public Response<ExpressRouteLink> Get(string resourceGroupName, string expressRoutePortName, string linkName, Ca |
| | 115 | | { |
| 0 | 116 | | if (resourceGroupName == null) |
| | 117 | | { |
| 0 | 118 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 119 | | } |
| 0 | 120 | | if (expressRoutePortName == null) |
| | 121 | | { |
| 0 | 122 | | throw new ArgumentNullException(nameof(expressRoutePortName)); |
| | 123 | | } |
| 0 | 124 | | if (linkName == null) |
| | 125 | | { |
| 0 | 126 | | throw new ArgumentNullException(nameof(linkName)); |
| | 127 | | } |
| | 128 | |
|
| 0 | 129 | | using var message = CreateGetRequest(resourceGroupName, expressRoutePortName, linkName); |
| 0 | 130 | | _pipeline.Send(message, cancellationToken); |
| 0 | 131 | | switch (message.Response.Status) |
| | 132 | | { |
| | 133 | | case 200: |
| | 134 | | { |
| 0 | 135 | | ExpressRouteLink value = default; |
| 0 | 136 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 137 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 138 | | { |
| 0 | 139 | | value = null; |
| | 140 | | } |
| | 141 | | else |
| | 142 | | { |
| 0 | 143 | | value = ExpressRouteLink.DeserializeExpressRouteLink(document.RootElement); |
| | 144 | | } |
| 0 | 145 | | return Response.FromValue(value, message.Response); |
| | 146 | | } |
| | 147 | | default: |
| 0 | 148 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 149 | | } |
| 0 | 150 | | } |
| | 151 | |
|
| | 152 | | internal HttpMessage CreateListRequest(string resourceGroupName, string expressRoutePortName) |
| | 153 | | { |
| 0 | 154 | | var message = _pipeline.CreateMessage(); |
| 0 | 155 | | var request = message.Request; |
| 0 | 156 | | request.Method = RequestMethod.Get; |
| 0 | 157 | | var uri = new RawRequestUriBuilder(); |
| 0 | 158 | | uri.Reset(endpoint); |
| 0 | 159 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 160 | | uri.AppendPath(subscriptionId, true); |
| 0 | 161 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 162 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 163 | | uri.AppendPath("/providers/Microsoft.Network/ExpressRoutePorts/", false); |
| 0 | 164 | | uri.AppendPath(expressRoutePortName, true); |
| 0 | 165 | | uri.AppendPath("/links", false); |
| 0 | 166 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 167 | | request.Uri = uri; |
| 0 | 168 | | return message; |
| | 169 | | } |
| | 170 | |
|
| | 171 | | /// <summary> Retrieve the ExpressRouteLink sub-resources of the specified ExpressRoutePort resource. </summary> |
| | 172 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 173 | | /// <param name="expressRoutePortName"> The name of the ExpressRoutePort resource. </param> |
| | 174 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 175 | | public async Task<Response<ExpressRouteLinkListResult>> ListAsync(string resourceGroupName, string expressRouteP |
| | 176 | | { |
| 0 | 177 | | if (resourceGroupName == null) |
| | 178 | | { |
| 0 | 179 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 180 | | } |
| 0 | 181 | | if (expressRoutePortName == null) |
| | 182 | | { |
| 0 | 183 | | throw new ArgumentNullException(nameof(expressRoutePortName)); |
| | 184 | | } |
| | 185 | |
|
| 0 | 186 | | using var message = CreateListRequest(resourceGroupName, expressRoutePortName); |
| 0 | 187 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 188 | | switch (message.Response.Status) |
| | 189 | | { |
| | 190 | | case 200: |
| | 191 | | { |
| 0 | 192 | | ExpressRouteLinkListResult value = default; |
| 0 | 193 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 194 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 195 | | { |
| 0 | 196 | | value = null; |
| | 197 | | } |
| | 198 | | else |
| | 199 | | { |
| 0 | 200 | | value = ExpressRouteLinkListResult.DeserializeExpressRouteLinkListResult(document.RootElemen |
| | 201 | | } |
| 0 | 202 | | return Response.FromValue(value, message.Response); |
| | 203 | | } |
| | 204 | | default: |
| 0 | 205 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 206 | | } |
| 0 | 207 | | } |
| | 208 | |
|
| | 209 | | /// <summary> Retrieve the ExpressRouteLink sub-resources of the specified ExpressRoutePort resource. </summary> |
| | 210 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 211 | | /// <param name="expressRoutePortName"> The name of the ExpressRoutePort resource. </param> |
| | 212 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 213 | | public Response<ExpressRouteLinkListResult> List(string resourceGroupName, string expressRoutePortName, Cancella |
| | 214 | | { |
| 0 | 215 | | if (resourceGroupName == null) |
| | 216 | | { |
| 0 | 217 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 218 | | } |
| 0 | 219 | | if (expressRoutePortName == null) |
| | 220 | | { |
| 0 | 221 | | throw new ArgumentNullException(nameof(expressRoutePortName)); |
| | 222 | | } |
| | 223 | |
|
| 0 | 224 | | using var message = CreateListRequest(resourceGroupName, expressRoutePortName); |
| 0 | 225 | | _pipeline.Send(message, cancellationToken); |
| 0 | 226 | | switch (message.Response.Status) |
| | 227 | | { |
| | 228 | | case 200: |
| | 229 | | { |
| 0 | 230 | | ExpressRouteLinkListResult value = default; |
| 0 | 231 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 232 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 233 | | { |
| 0 | 234 | | value = null; |
| | 235 | | } |
| | 236 | | else |
| | 237 | | { |
| 0 | 238 | | value = ExpressRouteLinkListResult.DeserializeExpressRouteLinkListResult(document.RootElemen |
| | 239 | | } |
| 0 | 240 | | return Response.FromValue(value, message.Response); |
| | 241 | | } |
| | 242 | | default: |
| 0 | 243 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 244 | | } |
| 0 | 245 | | } |
| | 246 | |
|
| | 247 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string expressRoutePor |
| | 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> Retrieve the ExpressRouteLink sub-resources of the specified ExpressRoutePort resource. </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="expressRoutePortName"> The name of the ExpressRoutePort resource. </param> |
| | 263 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 264 | | public async Task<Response<ExpressRouteLinkListResult>> ListNextPageAsync(string nextLink, string resourceGroupN |
| | 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 (expressRoutePortName == null) |
| | 275 | | { |
| 0 | 276 | | throw new ArgumentNullException(nameof(expressRoutePortName)); |
| | 277 | | } |
| | 278 | |
|
| 0 | 279 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, expressRoutePortName); |
| 0 | 280 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 281 | | switch (message.Response.Status) |
| | 282 | | { |
| | 283 | | case 200: |
| | 284 | | { |
| 0 | 285 | | ExpressRouteLinkListResult 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 = ExpressRouteLinkListResult.DeserializeExpressRouteLinkListResult(document.RootElemen |
| | 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> Retrieve the ExpressRouteLink sub-resources of the specified ExpressRoutePort resource. </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="expressRoutePortName"> The name of the ExpressRoutePort resource. </param> |
| | 306 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 307 | | public Response<ExpressRouteLinkListResult> ListNextPage(string nextLink, string resourceGroupName, string expre |
| | 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 (expressRoutePortName == null) |
| | 318 | | { |
| 0 | 319 | | throw new ArgumentNullException(nameof(expressRoutePortName)); |
| | 320 | | } |
| | 321 | |
|
| 0 | 322 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, expressRoutePortName); |
| 0 | 323 | | _pipeline.Send(message, cancellationToken); |
| 0 | 324 | | switch (message.Response.Status) |
| | 325 | | { |
| | 326 | | case 200: |
| | 327 | | { |
| 0 | 328 | | ExpressRouteLinkListResult 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 = ExpressRouteLinkListResult.DeserializeExpressRouteLinkListResult(document.RootElemen |
| | 337 | | } |
| 0 | 338 | | return Response.FromValue(value, message.Response); |
| | 339 | | } |
| | 340 | | default: |
| 0 | 341 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 342 | | } |
| 0 | 343 | | } |
| | 344 | | } |
| | 345 | | } |