< Summary

Class:Azure.ResourceManager.Network.PacketCapturesRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\PacketCapturesRestOperations.cs
Covered lines:221
Uncovered lines:53
Coverable lines:274
Total lines:597
Line coverage:80.6% (221 of 274)
Covered branches:64
Total branches:120
Branch coverage:53.3% (64 of 120)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateCreateRequest(...)-100%100%
CreateAsync()-64.29%50%
Create(...)-64.29%50%
CreateGetRequest(...)-100%100%
GetAsync()-70.59%50%
Get(...)-70.59%50%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-66.67%50%
Delete(...)-66.67%50%
CreateStopRequest(...)-100%100%
StopAsync()-66.67%60%
Stop(...)-66.67%60%
CreateGetStatusRequest(...)-100%100%
GetStatusAsync()-66.67%60%
GetStatus(...)-66.67%60%
CreateListRequest(...)-100%100%
ListAsync()-73.33%50%
List(...)-73.33%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\PacketCapturesRestOperations.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 PacketCapturesRestOperations
 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 PacketCapturesRestOperations. </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
 3632        public PacketCapturesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscript
 33        {
 3634            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 3638            endpoint ??= new Uri("https://management.azure.com");
 39
 3640            this.subscriptionId = subscriptionId;
 3641            this.endpoint = endpoint;
 3642            _clientDiagnostics = clientDiagnostics;
 3643            _pipeline = pipeline;
 3644        }
 45
 46        internal HttpMessage CreateCreateRequest(string resourceGroupName, string networkWatcherName, string packetCaptu
 47        {
 1648            var message = _pipeline.CreateMessage();
 1649            var request = message.Request;
 1650            request.Method = RequestMethod.Put;
 1651            var uri = new RawRequestUriBuilder();
 1652            uri.Reset(endpoint);
 1653            uri.AppendPath("/subscriptions/", false);
 1654            uri.AppendPath(subscriptionId, true);
 1655            uri.AppendPath("/resourceGroups/", false);
 1656            uri.AppendPath(resourceGroupName, true);
 1657            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 1658            uri.AppendPath(networkWatcherName, true);
 1659            uri.AppendPath("/packetCaptures/", false);
 1660            uri.AppendPath(packetCaptureName, true);
 1661            uri.AppendQuery("api-version", "2020-04-01", true);
 1662            request.Uri = uri;
 1663            request.Headers.Add("Content-Type", "application/json");
 1664            var content = new Utf8JsonRequestContent();
 1665            content.JsonWriter.WriteObjectValue(parameters);
 1666            request.Content = content;
 1667            return message;
 68        }
 69
 70        /// <summary> Create and start a packet capture on the specified VM. </summary>
 71        /// <param name="resourceGroupName"> The name of the resource group. </param>
 72        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 73        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 74        /// <param name="parameters"> Parameters that define the create packet capture operation. </param>
 75        /// <param name="cancellationToken"> The cancellation token to use. </param>
 76        public async Task<Response> CreateAsync(string resourceGroupName, string networkWatcherName, string packetCaptur
 77        {
 478            if (resourceGroupName == null)
 79            {
 080                throw new ArgumentNullException(nameof(resourceGroupName));
 81            }
 482            if (networkWatcherName == null)
 83            {
 084                throw new ArgumentNullException(nameof(networkWatcherName));
 85            }
 486            if (packetCaptureName == null)
 87            {
 088                throw new ArgumentNullException(nameof(packetCaptureName));
 89            }
 490            if (parameters == null)
 91            {
 092                throw new ArgumentNullException(nameof(parameters));
 93            }
 94
 495            using var message = CreateCreateRequest(resourceGroupName, networkWatcherName, packetCaptureName, parameters
 496            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 497            switch (message.Response.Status)
 98            {
 99                case 201:
 4100                    return message.Response;
 101                default:
 0102                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 103            }
 4104        }
 105
 106        /// <summary> Create and start a packet capture on the specified VM. </summary>
 107        /// <param name="resourceGroupName"> The name of the resource group. </param>
 108        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 109        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 110        /// <param name="parameters"> Parameters that define the create packet capture operation. </param>
 111        /// <param name="cancellationToken"> The cancellation token to use. </param>
 112        public Response Create(string resourceGroupName, string networkWatcherName, string packetCaptureName, PacketCapt
 113        {
 4114            if (resourceGroupName == null)
 115            {
 0116                throw new ArgumentNullException(nameof(resourceGroupName));
 117            }
 4118            if (networkWatcherName == null)
 119            {
 0120                throw new ArgumentNullException(nameof(networkWatcherName));
 121            }
 4122            if (packetCaptureName == null)
 123            {
 0124                throw new ArgumentNullException(nameof(packetCaptureName));
 125            }
 4126            if (parameters == null)
 127            {
 0128                throw new ArgumentNullException(nameof(parameters));
 129            }
 130
 4131            using var message = CreateCreateRequest(resourceGroupName, networkWatcherName, packetCaptureName, parameters
 4132            _pipeline.Send(message, cancellationToken);
 4133            switch (message.Response.Status)
 134            {
 135                case 201:
 4136                    return message.Response;
 137                default:
 0138                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 139            }
 4140        }
 141
 142        internal HttpMessage CreateGetRequest(string resourceGroupName, string networkWatcherName, string packetCaptureN
 143        {
 4144            var message = _pipeline.CreateMessage();
 4145            var request = message.Request;
 4146            request.Method = RequestMethod.Get;
 4147            var uri = new RawRequestUriBuilder();
 4148            uri.Reset(endpoint);
 4149            uri.AppendPath("/subscriptions/", false);
 4150            uri.AppendPath(subscriptionId, true);
 4151            uri.AppendPath("/resourceGroups/", false);
 4152            uri.AppendPath(resourceGroupName, true);
 4153            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 4154            uri.AppendPath(networkWatcherName, true);
 4155            uri.AppendPath("/packetCaptures/", false);
 4156            uri.AppendPath(packetCaptureName, true);
 4157            uri.AppendQuery("api-version", "2020-04-01", true);
 4158            request.Uri = uri;
 4159            return message;
 160        }
 161
 162        /// <summary> Gets a packet capture session by name. </summary>
 163        /// <param name="resourceGroupName"> The name of the resource group. </param>
 164        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 165        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 166        /// <param name="cancellationToken"> The cancellation token to use. </param>
 167        public async Task<Response<PacketCaptureResult>> GetAsync(string resourceGroupName, string networkWatcherName, s
 168        {
 2169            if (resourceGroupName == null)
 170            {
 0171                throw new ArgumentNullException(nameof(resourceGroupName));
 172            }
 2173            if (networkWatcherName == null)
 174            {
 0175                throw new ArgumentNullException(nameof(networkWatcherName));
 176            }
 2177            if (packetCaptureName == null)
 178            {
 0179                throw new ArgumentNullException(nameof(packetCaptureName));
 180            }
 181
 2182            using var message = CreateGetRequest(resourceGroupName, networkWatcherName, packetCaptureName);
 2183            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2184            switch (message.Response.Status)
 185            {
 186                case 200:
 187                    {
 2188                        PacketCaptureResult value = default;
 2189                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2190                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 191                        {
 0192                            value = null;
 193                        }
 194                        else
 195                        {
 2196                            value = PacketCaptureResult.DeserializePacketCaptureResult(document.RootElement);
 197                        }
 2198                        return Response.FromValue(value, message.Response);
 199                    }
 200                default:
 0201                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 202            }
 2203        }
 204
 205        /// <summary> Gets a packet capture session by name. </summary>
 206        /// <param name="resourceGroupName"> The name of the resource group. </param>
 207        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 208        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 209        /// <param name="cancellationToken"> The cancellation token to use. </param>
 210        public Response<PacketCaptureResult> Get(string resourceGroupName, string networkWatcherName, string packetCaptu
 211        {
 2212            if (resourceGroupName == null)
 213            {
 0214                throw new ArgumentNullException(nameof(resourceGroupName));
 215            }
 2216            if (networkWatcherName == null)
 217            {
 0218                throw new ArgumentNullException(nameof(networkWatcherName));
 219            }
 2220            if (packetCaptureName == null)
 221            {
 0222                throw new ArgumentNullException(nameof(packetCaptureName));
 223            }
 224
 2225            using var message = CreateGetRequest(resourceGroupName, networkWatcherName, packetCaptureName);
 2226            _pipeline.Send(message, cancellationToken);
 2227            switch (message.Response.Status)
 228            {
 229                case 200:
 230                    {
 2231                        PacketCaptureResult value = default;
 2232                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2233                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 234                        {
 0235                            value = null;
 236                        }
 237                        else
 238                        {
 2239                            value = PacketCaptureResult.DeserializePacketCaptureResult(document.RootElement);
 240                        }
 2241                        return Response.FromValue(value, message.Response);
 242                    }
 243                default:
 0244                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 245            }
 2246        }
 247
 248        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string networkWatcherName, string packetCaptu
 249        {
 8250            var message = _pipeline.CreateMessage();
 8251            var request = message.Request;
 8252            request.Method = RequestMethod.Delete;
 8253            var uri = new RawRequestUriBuilder();
 8254            uri.Reset(endpoint);
 8255            uri.AppendPath("/subscriptions/", false);
 8256            uri.AppendPath(subscriptionId, true);
 8257            uri.AppendPath("/resourceGroups/", false);
 8258            uri.AppendPath(resourceGroupName, true);
 8259            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 8260            uri.AppendPath(networkWatcherName, true);
 8261            uri.AppendPath("/packetCaptures/", false);
 8262            uri.AppendPath(packetCaptureName, true);
 8263            uri.AppendQuery("api-version", "2020-04-01", true);
 8264            request.Uri = uri;
 8265            return message;
 266        }
 267
 268        /// <summary> Deletes the specified packet capture session. </summary>
 269        /// <param name="resourceGroupName"> The name of the resource group. </param>
 270        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 271        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 272        /// <param name="cancellationToken"> The cancellation token to use. </param>
 273        public async Task<Response> DeleteAsync(string resourceGroupName, string networkWatcherName, string packetCaptur
 274        {
 2275            if (resourceGroupName == null)
 276            {
 0277                throw new ArgumentNullException(nameof(resourceGroupName));
 278            }
 2279            if (networkWatcherName == null)
 280            {
 0281                throw new ArgumentNullException(nameof(networkWatcherName));
 282            }
 2283            if (packetCaptureName == null)
 284            {
 0285                throw new ArgumentNullException(nameof(packetCaptureName));
 286            }
 287
 2288            using var message = CreateDeleteRequest(resourceGroupName, networkWatcherName, packetCaptureName);
 2289            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2290            switch (message.Response.Status)
 291            {
 292                case 202:
 293                case 204:
 2294                    return message.Response;
 295                default:
 0296                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 297            }
 2298        }
 299
 300        /// <summary> Deletes the specified packet capture session. </summary>
 301        /// <param name="resourceGroupName"> The name of the resource group. </param>
 302        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 303        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 304        /// <param name="cancellationToken"> The cancellation token to use. </param>
 305        public Response Delete(string resourceGroupName, string networkWatcherName, string packetCaptureName, Cancellati
 306        {
 2307            if (resourceGroupName == null)
 308            {
 0309                throw new ArgumentNullException(nameof(resourceGroupName));
 310            }
 2311            if (networkWatcherName == null)
 312            {
 0313                throw new ArgumentNullException(nameof(networkWatcherName));
 314            }
 2315            if (packetCaptureName == null)
 316            {
 0317                throw new ArgumentNullException(nameof(packetCaptureName));
 318            }
 319
 2320            using var message = CreateDeleteRequest(resourceGroupName, networkWatcherName, packetCaptureName);
 2321            _pipeline.Send(message, cancellationToken);
 2322            switch (message.Response.Status)
 323            {
 324                case 202:
 325                case 204:
 2326                    return message.Response;
 327                default:
 0328                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 329            }
 2330        }
 331
 332        internal HttpMessage CreateStopRequest(string resourceGroupName, string networkWatcherName, string packetCapture
 333        {
 8334            var message = _pipeline.CreateMessage();
 8335            var request = message.Request;
 8336            request.Method = RequestMethod.Post;
 8337            var uri = new RawRequestUriBuilder();
 8338            uri.Reset(endpoint);
 8339            uri.AppendPath("/subscriptions/", false);
 8340            uri.AppendPath(subscriptionId, true);
 8341            uri.AppendPath("/resourceGroups/", false);
 8342            uri.AppendPath(resourceGroupName, true);
 8343            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 8344            uri.AppendPath(networkWatcherName, true);
 8345            uri.AppendPath("/packetCaptures/", false);
 8346            uri.AppendPath(packetCaptureName, true);
 8347            uri.AppendPath("/stop", false);
 8348            uri.AppendQuery("api-version", "2020-04-01", true);
 8349            request.Uri = uri;
 8350            return message;
 351        }
 352
 353        /// <summary> Stops a specified packet capture session. </summary>
 354        /// <param name="resourceGroupName"> The name of the resource group. </param>
 355        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 356        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 357        /// <param name="cancellationToken"> The cancellation token to use. </param>
 358        public async Task<Response> StopAsync(string resourceGroupName, string networkWatcherName, string packetCaptureN
 359        {
 2360            if (resourceGroupName == null)
 361            {
 0362                throw new ArgumentNullException(nameof(resourceGroupName));
 363            }
 2364            if (networkWatcherName == null)
 365            {
 0366                throw new ArgumentNullException(nameof(networkWatcherName));
 367            }
 2368            if (packetCaptureName == null)
 369            {
 0370                throw new ArgumentNullException(nameof(packetCaptureName));
 371            }
 372
 2373            using var message = CreateStopRequest(resourceGroupName, networkWatcherName, packetCaptureName);
 2374            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2375            switch (message.Response.Status)
 376            {
 377                case 200:
 378                case 202:
 2379                    return message.Response;
 380                default:
 0381                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 382            }
 2383        }
 384
 385        /// <summary> Stops a specified packet capture session. </summary>
 386        /// <param name="resourceGroupName"> The name of the resource group. </param>
 387        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 388        /// <param name="packetCaptureName"> The name of the packet capture session. </param>
 389        /// <param name="cancellationToken"> The cancellation token to use. </param>
 390        public Response Stop(string resourceGroupName, string networkWatcherName, string packetCaptureName, Cancellation
 391        {
 2392            if (resourceGroupName == null)
 393            {
 0394                throw new ArgumentNullException(nameof(resourceGroupName));
 395            }
 2396            if (networkWatcherName == null)
 397            {
 0398                throw new ArgumentNullException(nameof(networkWatcherName));
 399            }
 2400            if (packetCaptureName == null)
 401            {
 0402                throw new ArgumentNullException(nameof(packetCaptureName));
 403            }
 404
 2405            using var message = CreateStopRequest(resourceGroupName, networkWatcherName, packetCaptureName);
 2406            _pipeline.Send(message, cancellationToken);
 2407            switch (message.Response.Status)
 408            {
 409                case 200:
 410                case 202:
 2411                    return message.Response;
 412                default:
 0413                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 414            }
 2415        }
 416
 417        internal HttpMessage CreateGetStatusRequest(string resourceGroupName, string networkWatcherName, string packetCa
 418        {
 16419            var message = _pipeline.CreateMessage();
 16420            var request = message.Request;
 16421            request.Method = RequestMethod.Post;
 16422            var uri = new RawRequestUriBuilder();
 16423            uri.Reset(endpoint);
 16424            uri.AppendPath("/subscriptions/", false);
 16425            uri.AppendPath(subscriptionId, true);
 16426            uri.AppendPath("/resourceGroups/", false);
 16427            uri.AppendPath(resourceGroupName, true);
 16428            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 16429            uri.AppendPath(networkWatcherName, true);
 16430            uri.AppendPath("/packetCaptures/", false);
 16431            uri.AppendPath(packetCaptureName, true);
 16432            uri.AppendPath("/queryStatus", false);
 16433            uri.AppendQuery("api-version", "2020-04-01", true);
 16434            request.Uri = uri;
 16435            return message;
 436        }
 437
 438        /// <summary> Query the status of a running packet capture session. </summary>
 439        /// <param name="resourceGroupName"> The name of the resource group. </param>
 440        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 441        /// <param name="packetCaptureName"> The name given to the packet capture session. </param>
 442        /// <param name="cancellationToken"> The cancellation token to use. </param>
 443        public async Task<Response> GetStatusAsync(string resourceGroupName, string networkWatcherName, string packetCap
 444        {
 4445            if (resourceGroupName == null)
 446            {
 0447                throw new ArgumentNullException(nameof(resourceGroupName));
 448            }
 4449            if (networkWatcherName == null)
 450            {
 0451                throw new ArgumentNullException(nameof(networkWatcherName));
 452            }
 4453            if (packetCaptureName == null)
 454            {
 0455                throw new ArgumentNullException(nameof(packetCaptureName));
 456            }
 457
 4458            using var message = CreateGetStatusRequest(resourceGroupName, networkWatcherName, packetCaptureName);
 4459            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4460            switch (message.Response.Status)
 461            {
 462                case 200:
 463                case 202:
 4464                    return message.Response;
 465                default:
 0466                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 467            }
 4468        }
 469
 470        /// <summary> Query the status of a running packet capture session. </summary>
 471        /// <param name="resourceGroupName"> The name of the resource group. </param>
 472        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 473        /// <param name="packetCaptureName"> The name given to the packet capture session. </param>
 474        /// <param name="cancellationToken"> The cancellation token to use. </param>
 475        public Response GetStatus(string resourceGroupName, string networkWatcherName, string packetCaptureName, Cancell
 476        {
 4477            if (resourceGroupName == null)
 478            {
 0479                throw new ArgumentNullException(nameof(resourceGroupName));
 480            }
 4481            if (networkWatcherName == null)
 482            {
 0483                throw new ArgumentNullException(nameof(networkWatcherName));
 484            }
 4485            if (packetCaptureName == null)
 486            {
 0487                throw new ArgumentNullException(nameof(packetCaptureName));
 488            }
 489
 4490            using var message = CreateGetStatusRequest(resourceGroupName, networkWatcherName, packetCaptureName);
 4491            _pipeline.Send(message, cancellationToken);
 4492            switch (message.Response.Status)
 493            {
 494                case 200:
 495                case 202:
 4496                    return message.Response;
 497                default:
 0498                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 499            }
 4500        }
 501
 502        internal HttpMessage CreateListRequest(string resourceGroupName, string networkWatcherName)
 503        {
 4504            var message = _pipeline.CreateMessage();
 4505            var request = message.Request;
 4506            request.Method = RequestMethod.Get;
 4507            var uri = new RawRequestUriBuilder();
 4508            uri.Reset(endpoint);
 4509            uri.AppendPath("/subscriptions/", false);
 4510            uri.AppendPath(subscriptionId, true);
 4511            uri.AppendPath("/resourceGroups/", false);
 4512            uri.AppendPath(resourceGroupName, true);
 4513            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 4514            uri.AppendPath(networkWatcherName, true);
 4515            uri.AppendPath("/packetCaptures", false);
 4516            uri.AppendQuery("api-version", "2020-04-01", true);
 4517            request.Uri = uri;
 4518            return message;
 519        }
 520
 521        /// <summary> Lists all packet capture sessions within the specified resource group. </summary>
 522        /// <param name="resourceGroupName"> The name of the resource group. </param>
 523        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 524        /// <param name="cancellationToken"> The cancellation token to use. </param>
 525        public async Task<Response<PacketCaptureListResult>> ListAsync(string resourceGroupName, string networkWatcherNa
 526        {
 2527            if (resourceGroupName == null)
 528            {
 0529                throw new ArgumentNullException(nameof(resourceGroupName));
 530            }
 2531            if (networkWatcherName == null)
 532            {
 0533                throw new ArgumentNullException(nameof(networkWatcherName));
 534            }
 535
 2536            using var message = CreateListRequest(resourceGroupName, networkWatcherName);
 2537            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2538            switch (message.Response.Status)
 539            {
 540                case 200:
 541                    {
 2542                        PacketCaptureListResult value = default;
 2543                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2544                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 545                        {
 0546                            value = null;
 547                        }
 548                        else
 549                        {
 2550                            value = PacketCaptureListResult.DeserializePacketCaptureListResult(document.RootElement);
 551                        }
 2552                        return Response.FromValue(value, message.Response);
 553                    }
 554                default:
 0555                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 556            }
 2557        }
 558
 559        /// <summary> Lists all packet capture sessions within the specified resource group. </summary>
 560        /// <param name="resourceGroupName"> The name of the resource group. </param>
 561        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 562        /// <param name="cancellationToken"> The cancellation token to use. </param>
 563        public Response<PacketCaptureListResult> List(string resourceGroupName, string networkWatcherName, CancellationT
 564        {
 2565            if (resourceGroupName == null)
 566            {
 0567                throw new ArgumentNullException(nameof(resourceGroupName));
 568            }
 2569            if (networkWatcherName == null)
 570            {
 0571                throw new ArgumentNullException(nameof(networkWatcherName));
 572            }
 573
 2574            using var message = CreateListRequest(resourceGroupName, networkWatcherName);
 2575            _pipeline.Send(message, cancellationToken);
 2576            switch (message.Response.Status)
 577            {
 578                case 200:
 579                    {
 2580                        PacketCaptureListResult value = default;
 2581                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2582                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 583                        {
 0584                            value = null;
 585                        }
 586                        else
 587                        {
 2588                            value = PacketCaptureListResult.DeserializePacketCaptureListResult(document.RootElement);
 589                        }
 2590                        return Response.FromValue(value, message.Response);
 591                    }
 592                default:
 0593                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 594            }
 2595        }
 596    }
 597}