< Summary

Class:Azure.ResourceManager.Network.VirtualNetworkPeeringsOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\VirtualNetworkPeeringsOperations.cs
Covered lines:66
Uncovered lines:58
Coverable lines:124
Total lines:322
Line coverage:53.2% (66 of 124)
Covered branches:18
Total branches:36
Branch coverage:50% (18 of 36)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
GetAsync()-57.14%100%
Get(...)-57.14%100%
ListAsync(...)-38.1%50%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
List(...)-38.1%50%
StartDeleteAsync()-57.14%50%
StartDelete(...)-57.14%50%
StartCreateOrUpdateAsync()-56.25%50%
StartCreateOrUpdate(...)-56.25%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\VirtualNetworkPeeringsOperations.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.Threading;
 10using System.Threading.Tasks;
 11using Azure;
 12using Azure.Core;
 13using Azure.Core.Pipeline;
 14using Azure.ResourceManager.Network.Models;
 15
 16namespace Azure.ResourceManager.Network
 17{
 18    /// <summary> The VirtualNetworkPeerings service client. </summary>
 19    public partial class VirtualNetworkPeeringsOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 6023        internal VirtualNetworkPeeringsRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of VirtualNetworkPeeringsOperations for mocking. </summary>
 4425        protected VirtualNetworkPeeringsOperations()
 26        {
 4427        }
 28        /// <summary> Initializes a new instance of VirtualNetworkPeeringsOperations. </summary>
 29        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 30        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 31        /// <param name="subscriptionId"> The subscription credentials which uniquely identify the Microsoft Azure subsc
 32        /// <param name="endpoint"> server parameter. </param>
 4433        internal VirtualNetworkPeeringsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string sub
 34        {
 4435            RestClient = new VirtualNetworkPeeringsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint)
 4436            _clientDiagnostics = clientDiagnostics;
 4437            _pipeline = pipeline;
 4438        }
 39
 40        /// <summary> Gets the specified virtual network peering. </summary>
 41        /// <param name="resourceGroupName"> The name of the resource group. </param>
 42        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 43        /// <param name="virtualNetworkPeeringName"> The name of the virtual network peering. </param>
 44        /// <param name="cancellationToken"> The cancellation token to use. </param>
 45        public virtual async Task<Response<VirtualNetworkPeering>> GetAsync(string resourceGroupName, string virtualNetw
 46        {
 447            using var scope = _clientDiagnostics.CreateScope("VirtualNetworkPeeringsOperations.Get");
 448            scope.Start();
 49            try
 50            {
 451                return await RestClient.GetAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, cance
 52            }
 053            catch (Exception e)
 54            {
 055                scope.Failed(e);
 056                throw;
 57            }
 458        }
 59
 60        /// <summary> Gets the specified virtual network peering. </summary>
 61        /// <param name="resourceGroupName"> The name of the resource group. </param>
 62        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 63        /// <param name="virtualNetworkPeeringName"> The name of the virtual network peering. </param>
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public virtual Response<VirtualNetworkPeering> Get(string resourceGroupName, string virtualNetworkName, string v
 66        {
 467            using var scope = _clientDiagnostics.CreateScope("VirtualNetworkPeeringsOperations.Get");
 468            scope.Start();
 69            try
 70            {
 471                return RestClient.Get(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, cancellationToke
 72            }
 073            catch (Exception e)
 74            {
 075                scope.Failed(e);
 076                throw;
 77            }
 478        }
 79
 80        /// <summary> Gets all virtual network peerings in a virtual network. </summary>
 81        /// <param name="resourceGroupName"> The name of the resource group. </param>
 82        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 83        /// <param name="cancellationToken"> The cancellation token to use. </param>
 84        public virtual AsyncPageable<VirtualNetworkPeering> ListAsync(string resourceGroupName, string virtualNetworkNam
 85        {
 1086            if (resourceGroupName == null)
 87            {
 088                throw new ArgumentNullException(nameof(resourceGroupName));
 89            }
 1090            if (virtualNetworkName == null)
 91            {
 092                throw new ArgumentNullException(nameof(virtualNetworkName));
 93            }
 94
 95            async Task<Page<VirtualNetworkPeering>> FirstPageFunc(int? pageSizeHint)
 96            {
 1097                using var scope = _clientDiagnostics.CreateScope("VirtualNetworkPeeringsOperations.List");
 1098                scope.Start();
 99                try
 100                {
 10101                    var response = await RestClient.ListAsync(resourceGroupName, virtualNetworkName, cancellationToken).
 10102                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 103                }
 0104                catch (Exception e)
 105                {
 0106                    scope.Failed(e);
 0107                    throw;
 108                }
 10109            }
 110            async Task<Page<VirtualNetworkPeering>> NextPageFunc(string nextLink, int? pageSizeHint)
 111            {
 0112                using var scope = _clientDiagnostics.CreateScope("VirtualNetworkPeeringsOperations.List");
 0113                scope.Start();
 114                try
 115                {
 0116                    var response = await RestClient.ListNextPageAsync(nextLink, resourceGroupName, virtualNetworkName, c
 0117                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 118                }
 0119                catch (Exception e)
 120                {
 0121                    scope.Failed(e);
 0122                    throw;
 123                }
 0124            }
 10125            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 126        }
 127
 128        /// <summary> Gets all virtual network peerings in a virtual network. </summary>
 129        /// <param name="resourceGroupName"> The name of the resource group. </param>
 130        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 131        /// <param name="cancellationToken"> The cancellation token to use. </param>
 132        public virtual Pageable<VirtualNetworkPeering> List(string resourceGroupName, string virtualNetworkName, Cancell
 133        {
 10134            if (resourceGroupName == null)
 135            {
 0136                throw new ArgumentNullException(nameof(resourceGroupName));
 137            }
 10138            if (virtualNetworkName == null)
 139            {
 0140                throw new ArgumentNullException(nameof(virtualNetworkName));
 141            }
 142
 143            Page<VirtualNetworkPeering> FirstPageFunc(int? pageSizeHint)
 144            {
 10145                using var scope = _clientDiagnostics.CreateScope("VirtualNetworkPeeringsOperations.List");
 10146                scope.Start();
 147                try
 148                {
 10149                    var response = RestClient.List(resourceGroupName, virtualNetworkName, cancellationToken);
 10150                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 151                }
 0152                catch (Exception e)
 153                {
 0154                    scope.Failed(e);
 0155                    throw;
 156                }
 10157            }
 158            Page<VirtualNetworkPeering> NextPageFunc(string nextLink, int? pageSizeHint)
 159            {
 0160                using var scope = _clientDiagnostics.CreateScope("VirtualNetworkPeeringsOperations.List");
 0161                scope.Start();
 162                try
 163                {
 0164                    var response = RestClient.ListNextPage(nextLink, resourceGroupName, virtualNetworkName, cancellation
 0165                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 166                }
 0167                catch (Exception e)
 168                {
 0169                    scope.Failed(e);
 0170                    throw;
 171                }
 0172            }
 10173            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 174        }
 175
 176        /// <summary> Deletes the specified virtual network peering. </summary>
 177        /// <param name="resourceGroupName"> The name of the resource group. </param>
 178        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 179        /// <param name="virtualNetworkPeeringName"> The name of the virtual network peering. </param>
 180        /// <param name="cancellationToken"> The cancellation token to use. </param>
 181        public virtual async Task<VirtualNetworkPeeringsDeleteOperation> StartDeleteAsync(string resourceGroupName, stri
 182        {
 4183            if (resourceGroupName == null)
 184            {
 0185                throw new ArgumentNullException(nameof(resourceGroupName));
 186            }
 4187            if (virtualNetworkName == null)
 188            {
 0189                throw new ArgumentNullException(nameof(virtualNetworkName));
 190            }
 4191            if (virtualNetworkPeeringName == null)
 192            {
 0193                throw new ArgumentNullException(nameof(virtualNetworkPeeringName));
 194            }
 195
 4196            using var scope = _clientDiagnostics.CreateScope("VirtualNetworkPeeringsOperations.StartDelete");
 4197            scope.Start();
 198            try
 199            {
 4200                var originalResponse = await RestClient.DeleteAsync(resourceGroupName, virtualNetworkName, virtualNetwor
 4201                return new VirtualNetworkPeeringsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteR
 202            }
 0203            catch (Exception e)
 204            {
 0205                scope.Failed(e);
 0206                throw;
 207            }
 4208        }
 209
 210        /// <summary> Deletes the specified virtual network peering. </summary>
 211        /// <param name="resourceGroupName"> The name of the resource group. </param>
 212        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 213        /// <param name="virtualNetworkPeeringName"> The name of the virtual network peering. </param>
 214        /// <param name="cancellationToken"> The cancellation token to use. </param>
 215        public virtual VirtualNetworkPeeringsDeleteOperation StartDelete(string resourceGroupName, string virtualNetwork
 216        {
 4217            if (resourceGroupName == null)
 218            {
 0219                throw new ArgumentNullException(nameof(resourceGroupName));
 220            }
 4221            if (virtualNetworkName == null)
 222            {
 0223                throw new ArgumentNullException(nameof(virtualNetworkName));
 224            }
 4225            if (virtualNetworkPeeringName == null)
 226            {
 0227                throw new ArgumentNullException(nameof(virtualNetworkPeeringName));
 228            }
 229
 4230            using var scope = _clientDiagnostics.CreateScope("VirtualNetworkPeeringsOperations.StartDelete");
 4231            scope.Start();
 232            try
 233            {
 4234                var originalResponse = RestClient.Delete(resourceGroupName, virtualNetworkName, virtualNetworkPeeringNam
 4235                return new VirtualNetworkPeeringsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteR
 236            }
 0237            catch (Exception e)
 238            {
 0239                scope.Failed(e);
 0240                throw;
 241            }
 4242        }
 243
 244        /// <summary> Creates or updates a peering in the specified virtual network. </summary>
 245        /// <param name="resourceGroupName"> The name of the resource group. </param>
 246        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 247        /// <param name="virtualNetworkPeeringName"> The name of the peering. </param>
 248        /// <param name="virtualNetworkPeeringParameters"> Parameters supplied to the create or update virtual network p
 249        /// <param name="cancellationToken"> The cancellation token to use. </param>
 250        public virtual async Task<VirtualNetworkPeeringsCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourc
 251        {
 4252            if (resourceGroupName == null)
 253            {
 0254                throw new ArgumentNullException(nameof(resourceGroupName));
 255            }
 4256            if (virtualNetworkName == null)
 257            {
 0258                throw new ArgumentNullException(nameof(virtualNetworkName));
 259            }
 4260            if (virtualNetworkPeeringName == null)
 261            {
 0262                throw new ArgumentNullException(nameof(virtualNetworkPeeringName));
 263            }
 4264            if (virtualNetworkPeeringParameters == null)
 265            {
 0266                throw new ArgumentNullException(nameof(virtualNetworkPeeringParameters));
 267            }
 268
 4269            using var scope = _clientDiagnostics.CreateScope("VirtualNetworkPeeringsOperations.StartCreateOrUpdate");
 4270            scope.Start();
 271            try
 272            {
 4273                var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, virtualNetworkName, virtu
 4274                return new VirtualNetworkPeeringsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.Creat
 275            }
 0276            catch (Exception e)
 277            {
 0278                scope.Failed(e);
 0279                throw;
 280            }
 4281        }
 282
 283        /// <summary> Creates or updates a peering in the specified virtual network. </summary>
 284        /// <param name="resourceGroupName"> The name of the resource group. </param>
 285        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 286        /// <param name="virtualNetworkPeeringName"> The name of the peering. </param>
 287        /// <param name="virtualNetworkPeeringParameters"> Parameters supplied to the create or update virtual network p
 288        /// <param name="cancellationToken"> The cancellation token to use. </param>
 289        public virtual VirtualNetworkPeeringsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, strin
 290        {
 4291            if (resourceGroupName == null)
 292            {
 0293                throw new ArgumentNullException(nameof(resourceGroupName));
 294            }
 4295            if (virtualNetworkName == null)
 296            {
 0297                throw new ArgumentNullException(nameof(virtualNetworkName));
 298            }
 4299            if (virtualNetworkPeeringName == null)
 300            {
 0301                throw new ArgumentNullException(nameof(virtualNetworkPeeringName));
 302            }
 4303            if (virtualNetworkPeeringParameters == null)
 304            {
 0305                throw new ArgumentNullException(nameof(virtualNetworkPeeringParameters));
 306            }
 307
 4308            using var scope = _clientDiagnostics.CreateScope("VirtualNetworkPeeringsOperations.StartCreateOrUpdate");
 4309            scope.Start();
 310            try
 311            {
 4312                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, virtualNetworkName, virtualNetworkPe
 4313                return new VirtualNetworkPeeringsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.Creat
 314            }
 0315            catch (Exception e)
 316            {
 0317                scope.Failed(e);
 0318                throw;
 319            }
 4320        }
 321    }
 322}