< Summary

Class:Azure.ResourceManager.Network.PacketCapturesOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\PacketCapturesOperations.cs
Covered lines:98
Uncovered lines:66
Coverable lines:164
Total lines:428
Line coverage:59.7% (98 of 164)
Covered branches:30
Total branches:60
Branch coverage:50% (30 of 60)

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(...)-61.54%50%
<ListAsync()-62.5%100%
List(...)-61.54%50%
StartCreateAsync()-56.25%50%
StartCreate(...)-56.25%50%
StartDeleteAsync()-57.14%50%
StartDelete(...)-57.14%50%
StartStopAsync()-57.14%50%
StartStop(...)-57.14%50%
StartGetStatusAsync()-57.14%50%
StartGetStatus(...)-57.14%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\PacketCapturesOperations.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 PacketCaptures service client. </summary>
 19    public partial class PacketCapturesOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 5623        internal PacketCapturesRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of PacketCapturesOperations for mocking. </summary>
 3625        protected PacketCapturesOperations()
 26        {
 3627        }
 28        /// <summary> Initializes a new instance of PacketCapturesOperations. </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>
 3633        internal PacketCapturesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio
 34        {
 3635            RestClient = new PacketCapturesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 3636            _clientDiagnostics = clientDiagnostics;
 3637            _pipeline = pipeline;
 3638        }
 39
 40        /// <summary> Gets a packet capture session by name. </summary>
 41        /// <param name="resourceGroupName"> The name of the resource group. </param>
 42        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 43        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 44        /// <param name="cancellationToken"> The cancellation token to use. </param>
 45        public virtual async Task<Response<PacketCaptureResult>> GetAsync(string resourceGroupName, string networkWatche
 46        {
 247            using var scope = _clientDiagnostics.CreateScope("PacketCapturesOperations.Get");
 248            scope.Start();
 49            try
 50            {
 251                return await RestClient.GetAsync(resourceGroupName, networkWatcherName, packetCaptureName, cancellationT
 52            }
 053            catch (Exception e)
 54            {
 055                scope.Failed(e);
 056                throw;
 57            }
 258        }
 59
 60        /// <summary> Gets a packet capture session by name. </summary>
 61        /// <param name="resourceGroupName"> The name of the resource group. </param>
 62        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 63        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public virtual Response<PacketCaptureResult> Get(string resourceGroupName, string networkWatcherName, string pac
 66        {
 267            using var scope = _clientDiagnostics.CreateScope("PacketCapturesOperations.Get");
 268            scope.Start();
 69            try
 70            {
 271                return RestClient.Get(resourceGroupName, networkWatcherName, packetCaptureName, cancellationToken);
 72            }
 073            catch (Exception e)
 74            {
 075                scope.Failed(e);
 076                throw;
 77            }
 278        }
 79
 80        /// <summary> Lists all packet capture sessions within the specified resource group. </summary>
 81        /// <param name="resourceGroupName"> The name of the resource group. </param>
 82        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 83        /// <param name="cancellationToken"> The cancellation token to use. </param>
 84        public virtual AsyncPageable<PacketCaptureResult> ListAsync(string resourceGroupName, string networkWatcherName,
 85        {
 486            if (resourceGroupName == null)
 87            {
 088                throw new ArgumentNullException(nameof(resourceGroupName));
 89            }
 490            if (networkWatcherName == null)
 91            {
 092                throw new ArgumentNullException(nameof(networkWatcherName));
 93            }
 94
 95            async Task<Page<PacketCaptureResult>> FirstPageFunc(int? pageSizeHint)
 96            {
 297                using var scope = _clientDiagnostics.CreateScope("PacketCapturesOperations.List");
 298                scope.Start();
 99                try
 100                {
 2101                    var response = await RestClient.ListAsync(resourceGroupName, networkWatcherName, cancellationToken).
 2102                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
 103                }
 0104                catch (Exception e)
 105                {
 0106                    scope.Failed(e);
 0107                    throw;
 108                }
 2109            }
 4110            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null);
 111        }
 112
 113        /// <summary> Lists all packet capture sessions within the specified resource group. </summary>
 114        /// <param name="resourceGroupName"> The name of the resource group. </param>
 115        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 116        /// <param name="cancellationToken"> The cancellation token to use. </param>
 117        public virtual Pageable<PacketCaptureResult> List(string resourceGroupName, string networkWatcherName, Cancellat
 118        {
 4119            if (resourceGroupName == null)
 120            {
 0121                throw new ArgumentNullException(nameof(resourceGroupName));
 122            }
 4123            if (networkWatcherName == null)
 124            {
 0125                throw new ArgumentNullException(nameof(networkWatcherName));
 126            }
 127
 128            Page<PacketCaptureResult> FirstPageFunc(int? pageSizeHint)
 129            {
 2130                using var scope = _clientDiagnostics.CreateScope("PacketCapturesOperations.List");
 2131                scope.Start();
 132                try
 133                {
 2134                    var response = RestClient.List(resourceGroupName, networkWatcherName, cancellationToken);
 2135                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
 136                }
 0137                catch (Exception e)
 138                {
 0139                    scope.Failed(e);
 0140                    throw;
 141                }
 2142            }
 4143            return PageableHelpers.CreateEnumerable(FirstPageFunc, null);
 144        }
 145
 146        /// <summary> Create and start a packet capture on the specified VM. </summary>
 147        /// <param name="resourceGroupName"> The name of the resource group. </param>
 148        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 149        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 150        /// <param name="parameters"> Parameters that define the create packet capture operation. </param>
 151        /// <param name="cancellationToken"> The cancellation token to use. </param>
 152        public virtual async Task<PacketCapturesCreateOperation> StartCreateAsync(string resourceGroupName, string netwo
 153        {
 4154            if (resourceGroupName == null)
 155            {
 0156                throw new ArgumentNullException(nameof(resourceGroupName));
 157            }
 4158            if (networkWatcherName == null)
 159            {
 0160                throw new ArgumentNullException(nameof(networkWatcherName));
 161            }
 4162            if (packetCaptureName == null)
 163            {
 0164                throw new ArgumentNullException(nameof(packetCaptureName));
 165            }
 4166            if (parameters == null)
 167            {
 0168                throw new ArgumentNullException(nameof(parameters));
 169            }
 170
 4171            using var scope = _clientDiagnostics.CreateScope("PacketCapturesOperations.StartCreate");
 4172            scope.Start();
 173            try
 174            {
 4175                var originalResponse = await RestClient.CreateAsync(resourceGroupName, networkWatcherName, packetCapture
 4176                return new PacketCapturesCreateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateRequest(r
 177            }
 0178            catch (Exception e)
 179            {
 0180                scope.Failed(e);
 0181                throw;
 182            }
 4183        }
 184
 185        /// <summary> Create and start a packet capture on the specified VM. </summary>
 186        /// <param name="resourceGroupName"> The name of the resource group. </param>
 187        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 188        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 189        /// <param name="parameters"> Parameters that define the create packet capture operation. </param>
 190        /// <param name="cancellationToken"> The cancellation token to use. </param>
 191        public virtual PacketCapturesCreateOperation StartCreate(string resourceGroupName, string networkWatcherName, st
 192        {
 4193            if (resourceGroupName == null)
 194            {
 0195                throw new ArgumentNullException(nameof(resourceGroupName));
 196            }
 4197            if (networkWatcherName == null)
 198            {
 0199                throw new ArgumentNullException(nameof(networkWatcherName));
 200            }
 4201            if (packetCaptureName == null)
 202            {
 0203                throw new ArgumentNullException(nameof(packetCaptureName));
 204            }
 4205            if (parameters == null)
 206            {
 0207                throw new ArgumentNullException(nameof(parameters));
 208            }
 209
 4210            using var scope = _clientDiagnostics.CreateScope("PacketCapturesOperations.StartCreate");
 4211            scope.Start();
 212            try
 213            {
 4214                var originalResponse = RestClient.Create(resourceGroupName, networkWatcherName, packetCaptureName, param
 4215                return new PacketCapturesCreateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateRequest(r
 216            }
 0217            catch (Exception e)
 218            {
 0219                scope.Failed(e);
 0220                throw;
 221            }
 4222        }
 223
 224        /// <summary> Deletes the specified packet capture session. </summary>
 225        /// <param name="resourceGroupName"> The name of the resource group. </param>
 226        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 227        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 228        /// <param name="cancellationToken"> The cancellation token to use. </param>
 229        public virtual async Task<PacketCapturesDeleteOperation> StartDeleteAsync(string resourceGroupName, string netwo
 230        {
 2231            if (resourceGroupName == null)
 232            {
 0233                throw new ArgumentNullException(nameof(resourceGroupName));
 234            }
 2235            if (networkWatcherName == null)
 236            {
 0237                throw new ArgumentNullException(nameof(networkWatcherName));
 238            }
 2239            if (packetCaptureName == null)
 240            {
 0241                throw new ArgumentNullException(nameof(packetCaptureName));
 242            }
 243
 2244            using var scope = _clientDiagnostics.CreateScope("PacketCapturesOperations.StartDelete");
 2245            scope.Start();
 246            try
 247            {
 2248                var originalResponse = await RestClient.DeleteAsync(resourceGroupName, networkWatcherName, packetCapture
 2249                return new PacketCapturesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(r
 250            }
 0251            catch (Exception e)
 252            {
 0253                scope.Failed(e);
 0254                throw;
 255            }
 2256        }
 257
 258        /// <summary> Deletes the specified packet capture session. </summary>
 259        /// <param name="resourceGroupName"> The name of the resource group. </param>
 260        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 261        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 262        /// <param name="cancellationToken"> The cancellation token to use. </param>
 263        public virtual PacketCapturesDeleteOperation StartDelete(string resourceGroupName, string networkWatcherName, st
 264        {
 2265            if (resourceGroupName == null)
 266            {
 0267                throw new ArgumentNullException(nameof(resourceGroupName));
 268            }
 2269            if (networkWatcherName == null)
 270            {
 0271                throw new ArgumentNullException(nameof(networkWatcherName));
 272            }
 2273            if (packetCaptureName == null)
 274            {
 0275                throw new ArgumentNullException(nameof(packetCaptureName));
 276            }
 277
 2278            using var scope = _clientDiagnostics.CreateScope("PacketCapturesOperations.StartDelete");
 2279            scope.Start();
 280            try
 281            {
 2282                var originalResponse = RestClient.Delete(resourceGroupName, networkWatcherName, packetCaptureName, cance
 2283                return new PacketCapturesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(r
 284            }
 0285            catch (Exception e)
 286            {
 0287                scope.Failed(e);
 0288                throw;
 289            }
 2290        }
 291
 292        /// <summary> Stops a specified packet capture session. </summary>
 293        /// <param name="resourceGroupName"> The name of the resource group. </param>
 294        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 295        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 296        /// <param name="cancellationToken"> The cancellation token to use. </param>
 297        public virtual async Task<PacketCapturesStopOperation> StartStopAsync(string resourceGroupName, string networkWa
 298        {
 2299            if (resourceGroupName == null)
 300            {
 0301                throw new ArgumentNullException(nameof(resourceGroupName));
 302            }
 2303            if (networkWatcherName == null)
 304            {
 0305                throw new ArgumentNullException(nameof(networkWatcherName));
 306            }
 2307            if (packetCaptureName == null)
 308            {
 0309                throw new ArgumentNullException(nameof(packetCaptureName));
 310            }
 311
 2312            using var scope = _clientDiagnostics.CreateScope("PacketCapturesOperations.StartStop");
 2313            scope.Start();
 314            try
 315            {
 2316                var originalResponse = await RestClient.StopAsync(resourceGroupName, networkWatcherName, packetCaptureNa
 2317                return new PacketCapturesStopOperation(_clientDiagnostics, _pipeline, RestClient.CreateStopRequest(resou
 318            }
 0319            catch (Exception e)
 320            {
 0321                scope.Failed(e);
 0322                throw;
 323            }
 2324        }
 325
 326        /// <summary> Stops a specified packet capture session. </summary>
 327        /// <param name="resourceGroupName"> The name of the resource group. </param>
 328        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 329        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 330        /// <param name="cancellationToken"> The cancellation token to use. </param>
 331        public virtual PacketCapturesStopOperation StartStop(string resourceGroupName, string networkWatcherName, string
 332        {
 2333            if (resourceGroupName == null)
 334            {
 0335                throw new ArgumentNullException(nameof(resourceGroupName));
 336            }
 2337            if (networkWatcherName == null)
 338            {
 0339                throw new ArgumentNullException(nameof(networkWatcherName));
 340            }
 2341            if (packetCaptureName == null)
 342            {
 0343                throw new ArgumentNullException(nameof(packetCaptureName));
 344            }
 345
 2346            using var scope = _clientDiagnostics.CreateScope("PacketCapturesOperations.StartStop");
 2347            scope.Start();
 348            try
 349            {
 2350                var originalResponse = RestClient.Stop(resourceGroupName, networkWatcherName, packetCaptureName, cancell
 2351                return new PacketCapturesStopOperation(_clientDiagnostics, _pipeline, RestClient.CreateStopRequest(resou
 352            }
 0353            catch (Exception e)
 354            {
 0355                scope.Failed(e);
 0356                throw;
 357            }
 2358        }
 359
 360        /// <summary> Query the status of a running packet capture session. </summary>
 361        /// <param name="resourceGroupName"> The name of the resource group. </param>
 362        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 363        /// <param name="packetCaptureName"> The name given to the packet capture session. </param>
 364        /// <param name="cancellationToken"> The cancellation token to use. </param>
 365        public virtual async Task<PacketCapturesGetStatusOperation> StartGetStatusAsync(string resourceGroupName, string
 366        {
 4367            if (resourceGroupName == null)
 368            {
 0369                throw new ArgumentNullException(nameof(resourceGroupName));
 370            }
 4371            if (networkWatcherName == null)
 372            {
 0373                throw new ArgumentNullException(nameof(networkWatcherName));
 374            }
 4375            if (packetCaptureName == null)
 376            {
 0377                throw new ArgumentNullException(nameof(packetCaptureName));
 378            }
 379
 4380            using var scope = _clientDiagnostics.CreateScope("PacketCapturesOperations.StartGetStatus");
 4381            scope.Start();
 382            try
 383            {
 4384                var originalResponse = await RestClient.GetStatusAsync(resourceGroupName, networkWatcherName, packetCapt
 4385                return new PacketCapturesGetStatusOperation(_clientDiagnostics, _pipeline, RestClient.CreateGetStatusReq
 386            }
 0387            catch (Exception e)
 388            {
 0389                scope.Failed(e);
 0390                throw;
 391            }
 4392        }
 393
 394        /// <summary> Query the status of a running packet capture session. </summary>
 395        /// <param name="resourceGroupName"> The name of the resource group. </param>
 396        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 397        /// <param name="packetCaptureName"> The name given to the packet capture session. </param>
 398        /// <param name="cancellationToken"> The cancellation token to use. </param>
 399        public virtual PacketCapturesGetStatusOperation StartGetStatus(string resourceGroupName, string networkWatcherNa
 400        {
 4401            if (resourceGroupName == null)
 402            {
 0403                throw new ArgumentNullException(nameof(resourceGroupName));
 404            }
 4405            if (networkWatcherName == null)
 406            {
 0407                throw new ArgumentNullException(nameof(networkWatcherName));
 408            }
 4409            if (packetCaptureName == null)
 410            {
 0411                throw new ArgumentNullException(nameof(packetCaptureName));
 412            }
 413
 4414            using var scope = _clientDiagnostics.CreateScope("PacketCapturesOperations.StartGetStatus");
 4415            scope.Start();
 416            try
 417            {
 4418                var originalResponse = RestClient.GetStatus(resourceGroupName, networkWatcherName, packetCaptureName, ca
 4419                return new PacketCapturesGetStatusOperation(_clientDiagnostics, _pipeline, RestClient.CreateGetStatusReq
 420            }
 0421            catch (Exception e)
 422            {
 0423                scope.Failed(e);
 0424                throw;
 425            }
 4426        }
 427    }
 428}