< Summary

Class:Azure.ResourceManager.Network.ExpressRouteCrossConnectionPeeringsRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\ExpressRouteCrossConnectionPeeringsRestOperations.cs
Covered lines:0
Uncovered lines:234
Coverable lines:234
Total lines:529
Line coverage:0% (0 of 234)
Covered branches:0
Total branches:104
Branch coverage:0% (0 of 104)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateListRequest(...)-0%100%
ListAsync()-0%0%
List(...)-0%0%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-0%0%
CreateGetRequest(...)-0%100%
GetAsync()-0%0%
Get(...)-0%0%
CreateCreateOrUpdateRequest(...)-0%100%
CreateOrUpdateAsync()-0%0%
CreateOrUpdate(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\ExpressRouteCrossConnectionPeeringsRestOperations.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Text.Json;
 10using System.Threading;
 11using System.Threading.Tasks;
 12using Azure;
 13using Azure.Core;
 14using Azure.Core.Pipeline;
 15using Azure.ResourceManager.Network.Models;
 16
 17namespace Azure.ResourceManager.Network
 18{
 19    internal partial class ExpressRouteCrossConnectionPeeringsRestOperations
 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 ExpressRouteCrossConnectionPeeringsRestOperations. </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
 032        public ExpressRouteCrossConnectionPeeringsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipel
 33        {
 034            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 038            endpoint ??= new Uri("https://management.azure.com");
 39
 040            this.subscriptionId = subscriptionId;
 041            this.endpoint = endpoint;
 042            _clientDiagnostics = clientDiagnostics;
 043            _pipeline = pipeline;
 044        }
 45
 46        internal HttpMessage CreateListRequest(string resourceGroupName, string crossConnectionName)
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Get;
 051            var uri = new RawRequestUriBuilder();
 052            uri.Reset(endpoint);
 053            uri.AppendPath("/subscriptions/", false);
 054            uri.AppendPath(subscriptionId, true);
 055            uri.AppendPath("/resourceGroups/", false);
 056            uri.AppendPath(resourceGroupName, true);
 057            uri.AppendPath("/providers/Microsoft.Network/expressRouteCrossConnections/", false);
 058            uri.AppendPath(crossConnectionName, true);
 059            uri.AppendPath("/peerings", false);
 060            uri.AppendQuery("api-version", "2020-04-01", true);
 061            request.Uri = uri;
 062            return message;
 63        }
 64
 65        /// <summary> Gets all peerings in a specified ExpressRouteCrossConnection. </summary>
 66        /// <param name="resourceGroupName"> The name of the resource group. </param>
 67        /// <param name="crossConnectionName"> The name of the ExpressRouteCrossConnection. </param>
 68        /// <param name="cancellationToken"> The cancellation token to use. </param>
 69        public async Task<Response<ExpressRouteCrossConnectionPeeringList>> ListAsync(string resourceGroupName, string c
 70        {
 071            if (resourceGroupName == null)
 72            {
 073                throw new ArgumentNullException(nameof(resourceGroupName));
 74            }
 075            if (crossConnectionName == null)
 76            {
 077                throw new ArgumentNullException(nameof(crossConnectionName));
 78            }
 79
 080            using var message = CreateListRequest(resourceGroupName, crossConnectionName);
 081            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 082            switch (message.Response.Status)
 83            {
 84                case 200:
 85                    {
 086                        ExpressRouteCrossConnectionPeeringList value = default;
 087                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 088                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 89                        {
 090                            value = null;
 91                        }
 92                        else
 93                        {
 094                            value = ExpressRouteCrossConnectionPeeringList.DeserializeExpressRouteCrossConnectionPeering
 95                        }
 096                        return Response.FromValue(value, message.Response);
 97                    }
 98                default:
 099                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 100            }
 0101        }
 102
 103        /// <summary> Gets all peerings in a specified ExpressRouteCrossConnection. </summary>
 104        /// <param name="resourceGroupName"> The name of the resource group. </param>
 105        /// <param name="crossConnectionName"> The name of the ExpressRouteCrossConnection. </param>
 106        /// <param name="cancellationToken"> The cancellation token to use. </param>
 107        public Response<ExpressRouteCrossConnectionPeeringList> List(string resourceGroupName, string crossConnectionNam
 108        {
 0109            if (resourceGroupName == null)
 110            {
 0111                throw new ArgumentNullException(nameof(resourceGroupName));
 112            }
 0113            if (crossConnectionName == null)
 114            {
 0115                throw new ArgumentNullException(nameof(crossConnectionName));
 116            }
 117
 0118            using var message = CreateListRequest(resourceGroupName, crossConnectionName);
 0119            _pipeline.Send(message, cancellationToken);
 0120            switch (message.Response.Status)
 121            {
 122                case 200:
 123                    {
 0124                        ExpressRouteCrossConnectionPeeringList value = default;
 0125                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0126                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 127                        {
 0128                            value = null;
 129                        }
 130                        else
 131                        {
 0132                            value = ExpressRouteCrossConnectionPeeringList.DeserializeExpressRouteCrossConnectionPeering
 133                        }
 0134                        return Response.FromValue(value, message.Response);
 135                    }
 136                default:
 0137                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 138            }
 0139        }
 140
 141        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string crossConnectionName, string peeringNam
 142        {
 0143            var message = _pipeline.CreateMessage();
 0144            var request = message.Request;
 0145            request.Method = RequestMethod.Delete;
 0146            var uri = new RawRequestUriBuilder();
 0147            uri.Reset(endpoint);
 0148            uri.AppendPath("/subscriptions/", false);
 0149            uri.AppendPath(subscriptionId, true);
 0150            uri.AppendPath("/resourceGroups/", false);
 0151            uri.AppendPath(resourceGroupName, true);
 0152            uri.AppendPath("/providers/Microsoft.Network/expressRouteCrossConnections/", false);
 0153            uri.AppendPath(crossConnectionName, true);
 0154            uri.AppendPath("/peerings/", false);
 0155            uri.AppendPath(peeringName, true);
 0156            uri.AppendQuery("api-version", "2020-04-01", true);
 0157            request.Uri = uri;
 0158            return message;
 159        }
 160
 161        /// <summary> Deletes the specified peering from the ExpressRouteCrossConnection. </summary>
 162        /// <param name="resourceGroupName"> The name of the resource group. </param>
 163        /// <param name="crossConnectionName"> The name of the ExpressRouteCrossConnection. </param>
 164        /// <param name="peeringName"> The name of the peering. </param>
 165        /// <param name="cancellationToken"> The cancellation token to use. </param>
 166        public async Task<Response> DeleteAsync(string resourceGroupName, string crossConnectionName, string peeringName
 167        {
 0168            if (resourceGroupName == null)
 169            {
 0170                throw new ArgumentNullException(nameof(resourceGroupName));
 171            }
 0172            if (crossConnectionName == null)
 173            {
 0174                throw new ArgumentNullException(nameof(crossConnectionName));
 175            }
 0176            if (peeringName == null)
 177            {
 0178                throw new ArgumentNullException(nameof(peeringName));
 179            }
 180
 0181            using var message = CreateDeleteRequest(resourceGroupName, crossConnectionName, peeringName);
 0182            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0183            switch (message.Response.Status)
 184            {
 185                case 200:
 186                case 202:
 187                case 204:
 0188                    return message.Response;
 189                default:
 0190                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 191            }
 0192        }
 193
 194        /// <summary> Deletes the specified peering from the ExpressRouteCrossConnection. </summary>
 195        /// <param name="resourceGroupName"> The name of the resource group. </param>
 196        /// <param name="crossConnectionName"> The name of the ExpressRouteCrossConnection. </param>
 197        /// <param name="peeringName"> The name of the peering. </param>
 198        /// <param name="cancellationToken"> The cancellation token to use. </param>
 199        public Response Delete(string resourceGroupName, string crossConnectionName, string peeringName, CancellationTok
 200        {
 0201            if (resourceGroupName == null)
 202            {
 0203                throw new ArgumentNullException(nameof(resourceGroupName));
 204            }
 0205            if (crossConnectionName == null)
 206            {
 0207                throw new ArgumentNullException(nameof(crossConnectionName));
 208            }
 0209            if (peeringName == null)
 210            {
 0211                throw new ArgumentNullException(nameof(peeringName));
 212            }
 213
 0214            using var message = CreateDeleteRequest(resourceGroupName, crossConnectionName, peeringName);
 0215            _pipeline.Send(message, cancellationToken);
 0216            switch (message.Response.Status)
 217            {
 218                case 200:
 219                case 202:
 220                case 204:
 0221                    return message.Response;
 222                default:
 0223                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 224            }
 0225        }
 226
 227        internal HttpMessage CreateGetRequest(string resourceGroupName, string crossConnectionName, string peeringName)
 228        {
 0229            var message = _pipeline.CreateMessage();
 0230            var request = message.Request;
 0231            request.Method = RequestMethod.Get;
 0232            var uri = new RawRequestUriBuilder();
 0233            uri.Reset(endpoint);
 0234            uri.AppendPath("/subscriptions/", false);
 0235            uri.AppendPath(subscriptionId, true);
 0236            uri.AppendPath("/resourceGroups/", false);
 0237            uri.AppendPath(resourceGroupName, true);
 0238            uri.AppendPath("/providers/Microsoft.Network/expressRouteCrossConnections/", false);
 0239            uri.AppendPath(crossConnectionName, true);
 0240            uri.AppendPath("/peerings/", false);
 0241            uri.AppendPath(peeringName, true);
 0242            uri.AppendQuery("api-version", "2020-04-01", true);
 0243            request.Uri = uri;
 0244            return message;
 245        }
 246
 247        /// <summary> Gets the specified peering for the ExpressRouteCrossConnection. </summary>
 248        /// <param name="resourceGroupName"> The name of the resource group. </param>
 249        /// <param name="crossConnectionName"> The name of the ExpressRouteCrossConnection. </param>
 250        /// <param name="peeringName"> The name of the peering. </param>
 251        /// <param name="cancellationToken"> The cancellation token to use. </param>
 252        public async Task<Response<ExpressRouteCrossConnectionPeering>> GetAsync(string resourceGroupName, string crossC
 253        {
 0254            if (resourceGroupName == null)
 255            {
 0256                throw new ArgumentNullException(nameof(resourceGroupName));
 257            }
 0258            if (crossConnectionName == null)
 259            {
 0260                throw new ArgumentNullException(nameof(crossConnectionName));
 261            }
 0262            if (peeringName == null)
 263            {
 0264                throw new ArgumentNullException(nameof(peeringName));
 265            }
 266
 0267            using var message = CreateGetRequest(resourceGroupName, crossConnectionName, peeringName);
 0268            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0269            switch (message.Response.Status)
 270            {
 271                case 200:
 272                    {
 0273                        ExpressRouteCrossConnectionPeering value = default;
 0274                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0275                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 276                        {
 0277                            value = null;
 278                        }
 279                        else
 280                        {
 0281                            value = ExpressRouteCrossConnectionPeering.DeserializeExpressRouteCrossConnectionPeering(doc
 282                        }
 0283                        return Response.FromValue(value, message.Response);
 284                    }
 285                default:
 0286                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 287            }
 0288        }
 289
 290        /// <summary> Gets the specified peering for the ExpressRouteCrossConnection. </summary>
 291        /// <param name="resourceGroupName"> The name of the resource group. </param>
 292        /// <param name="crossConnectionName"> The name of the ExpressRouteCrossConnection. </param>
 293        /// <param name="peeringName"> The name of the peering. </param>
 294        /// <param name="cancellationToken"> The cancellation token to use. </param>
 295        public Response<ExpressRouteCrossConnectionPeering> Get(string resourceGroupName, string crossConnectionName, st
 296        {
 0297            if (resourceGroupName == null)
 298            {
 0299                throw new ArgumentNullException(nameof(resourceGroupName));
 300            }
 0301            if (crossConnectionName == null)
 302            {
 0303                throw new ArgumentNullException(nameof(crossConnectionName));
 304            }
 0305            if (peeringName == null)
 306            {
 0307                throw new ArgumentNullException(nameof(peeringName));
 308            }
 309
 0310            using var message = CreateGetRequest(resourceGroupName, crossConnectionName, peeringName);
 0311            _pipeline.Send(message, cancellationToken);
 0312            switch (message.Response.Status)
 313            {
 314                case 200:
 315                    {
 0316                        ExpressRouteCrossConnectionPeering value = default;
 0317                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0318                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 319                        {
 0320                            value = null;
 321                        }
 322                        else
 323                        {
 0324                            value = ExpressRouteCrossConnectionPeering.DeserializeExpressRouteCrossConnectionPeering(doc
 325                        }
 0326                        return Response.FromValue(value, message.Response);
 327                    }
 328                default:
 0329                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 330            }
 0331        }
 332
 333        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string crossConnectionName, string pe
 334        {
 0335            var message = _pipeline.CreateMessage();
 0336            var request = message.Request;
 0337            request.Method = RequestMethod.Put;
 0338            var uri = new RawRequestUriBuilder();
 0339            uri.Reset(endpoint);
 0340            uri.AppendPath("/subscriptions/", false);
 0341            uri.AppendPath(subscriptionId, true);
 0342            uri.AppendPath("/resourceGroups/", false);
 0343            uri.AppendPath(resourceGroupName, true);
 0344            uri.AppendPath("/providers/Microsoft.Network/expressRouteCrossConnections/", false);
 0345            uri.AppendPath(crossConnectionName, true);
 0346            uri.AppendPath("/peerings/", false);
 0347            uri.AppendPath(peeringName, true);
 0348            uri.AppendQuery("api-version", "2020-04-01", true);
 0349            request.Uri = uri;
 0350            request.Headers.Add("Content-Type", "application/json");
 0351            var content = new Utf8JsonRequestContent();
 0352            content.JsonWriter.WriteObjectValue(peeringParameters);
 0353            request.Content = content;
 0354            return message;
 355        }
 356
 357        /// <summary> Creates or updates a peering in the specified ExpressRouteCrossConnection. </summary>
 358        /// <param name="resourceGroupName"> The name of the resource group. </param>
 359        /// <param name="crossConnectionName"> The name of the ExpressRouteCrossConnection. </param>
 360        /// <param name="peeringName"> The name of the peering. </param>
 361        /// <param name="peeringParameters"> Parameters supplied to the create or update ExpressRouteCrossConnection pee
 362        /// <param name="cancellationToken"> The cancellation token to use. </param>
 363        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string crossConnectionName, string pee
 364        {
 0365            if (resourceGroupName == null)
 366            {
 0367                throw new ArgumentNullException(nameof(resourceGroupName));
 368            }
 0369            if (crossConnectionName == null)
 370            {
 0371                throw new ArgumentNullException(nameof(crossConnectionName));
 372            }
 0373            if (peeringName == null)
 374            {
 0375                throw new ArgumentNullException(nameof(peeringName));
 376            }
 0377            if (peeringParameters == null)
 378            {
 0379                throw new ArgumentNullException(nameof(peeringParameters));
 380            }
 381
 0382            using var message = CreateCreateOrUpdateRequest(resourceGroupName, crossConnectionName, peeringName, peering
 0383            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0384            switch (message.Response.Status)
 385            {
 386                case 200:
 387                case 201:
 0388                    return message.Response;
 389                default:
 0390                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 391            }
 0392        }
 393
 394        /// <summary> Creates or updates a peering in the specified ExpressRouteCrossConnection. </summary>
 395        /// <param name="resourceGroupName"> The name of the resource group. </param>
 396        /// <param name="crossConnectionName"> The name of the ExpressRouteCrossConnection. </param>
 397        /// <param name="peeringName"> The name of the peering. </param>
 398        /// <param name="peeringParameters"> Parameters supplied to the create or update ExpressRouteCrossConnection pee
 399        /// <param name="cancellationToken"> The cancellation token to use. </param>
 400        public Response CreateOrUpdate(string resourceGroupName, string crossConnectionName, string peeringName, Express
 401        {
 0402            if (resourceGroupName == null)
 403            {
 0404                throw new ArgumentNullException(nameof(resourceGroupName));
 405            }
 0406            if (crossConnectionName == null)
 407            {
 0408                throw new ArgumentNullException(nameof(crossConnectionName));
 409            }
 0410            if (peeringName == null)
 411            {
 0412                throw new ArgumentNullException(nameof(peeringName));
 413            }
 0414            if (peeringParameters == null)
 415            {
 0416                throw new ArgumentNullException(nameof(peeringParameters));
 417            }
 418
 0419            using var message = CreateCreateOrUpdateRequest(resourceGroupName, crossConnectionName, peeringName, peering
 0420            _pipeline.Send(message, cancellationToken);
 0421            switch (message.Response.Status)
 422            {
 423                case 200:
 424                case 201:
 0425                    return message.Response;
 426                default:
 0427                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 428            }
 0429        }
 430
 431        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string crossConnection
 432        {
 0433            var message = _pipeline.CreateMessage();
 0434            var request = message.Request;
 0435            request.Method = RequestMethod.Get;
 0436            var uri = new RawRequestUriBuilder();
 0437            uri.Reset(endpoint);
 0438            uri.AppendRawNextLink(nextLink, false);
 0439            request.Uri = uri;
 0440            return message;
 441        }
 442
 443        /// <summary> Gets all peerings in a specified ExpressRouteCrossConnection. </summary>
 444        /// <param name="nextLink"> The URL to the next page of results. </param>
 445        /// <param name="resourceGroupName"> The name of the resource group. </param>
 446        /// <param name="crossConnectionName"> The name of the ExpressRouteCrossConnection. </param>
 447        /// <param name="cancellationToken"> The cancellation token to use. </param>
 448        public async Task<Response<ExpressRouteCrossConnectionPeeringList>> ListNextPageAsync(string nextLink, string re
 449        {
 0450            if (nextLink == null)
 451            {
 0452                throw new ArgumentNullException(nameof(nextLink));
 453            }
 0454            if (resourceGroupName == null)
 455            {
 0456                throw new ArgumentNullException(nameof(resourceGroupName));
 457            }
 0458            if (crossConnectionName == null)
 459            {
 0460                throw new ArgumentNullException(nameof(crossConnectionName));
 461            }
 462
 0463            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, crossConnectionName);
 0464            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0465            switch (message.Response.Status)
 466            {
 467                case 200:
 468                    {
 0469                        ExpressRouteCrossConnectionPeeringList value = default;
 0470                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0471                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 472                        {
 0473                            value = null;
 474                        }
 475                        else
 476                        {
 0477                            value = ExpressRouteCrossConnectionPeeringList.DeserializeExpressRouteCrossConnectionPeering
 478                        }
 0479                        return Response.FromValue(value, message.Response);
 480                    }
 481                default:
 0482                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 483            }
 0484        }
 485
 486        /// <summary> Gets all peerings in a specified ExpressRouteCrossConnection. </summary>
 487        /// <param name="nextLink"> The URL to the next page of results. </param>
 488        /// <param name="resourceGroupName"> The name of the resource group. </param>
 489        /// <param name="crossConnectionName"> The name of the ExpressRouteCrossConnection. </param>
 490        /// <param name="cancellationToken"> The cancellation token to use. </param>
 491        public Response<ExpressRouteCrossConnectionPeeringList> ListNextPage(string nextLink, string resourceGroupName, 
 492        {
 0493            if (nextLink == null)
 494            {
 0495                throw new ArgumentNullException(nameof(nextLink));
 496            }
 0497            if (resourceGroupName == null)
 498            {
 0499                throw new ArgumentNullException(nameof(resourceGroupName));
 500            }
 0501            if (crossConnectionName == null)
 502            {
 0503                throw new ArgumentNullException(nameof(crossConnectionName));
 504            }
 505
 0506            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, crossConnectionName);
 0507            _pipeline.Send(message, cancellationToken);
 0508            switch (message.Response.Status)
 509            {
 510                case 200:
 511                    {
 0512                        ExpressRouteCrossConnectionPeeringList value = default;
 0513                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0514                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 515                        {
 0516                            value = null;
 517                        }
 518                        else
 519                        {
 0520                            value = ExpressRouteCrossConnectionPeeringList.DeserializeExpressRouteCrossConnectionPeering
 521                        }
 0522                        return Response.FromValue(value, message.Response);
 523                    }
 524                default:
 0525                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 526            }
 0527        }
 528    }
 529}