< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateCreateOrUpdateRequest(...)-0%100%
CreateOrUpdateAsync()-0%0%
CreateOrUpdate(...)-0%0%
CreateGetRequest(...)-0%100%
GetAsync()-0%0%
Get(...)-0%0%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-0%0%
CreateUpdateTagsRequest(...)-0%100%
UpdateTagsAsync()-0%0%
UpdateTags(...)-0%0%
CreateStopRequest(...)-0%100%
StopAsync()-0%0%
Stop(...)-0%0%
CreateStartRequest(...)-0%100%
StartAsync()-0%0%
Start(...)-0%0%
CreateQueryRequest(...)-0%100%
QueryAsync()-0%0%
Query(...)-0%0%
CreateListRequest(...)-0%100%
ListAsync()-0%0%
List(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\ConnectionMonitorsRestOperations.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 ConnectionMonitorsRestOperations
 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 ConnectionMonitorsRestOperations. </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 ConnectionMonitorsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subsc
 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 CreateCreateOrUpdateRequest(string resourceGroupName, string networkWatcherName, string con
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Put;
 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/networkWatchers/", false);
 058            uri.AppendPath(networkWatcherName, true);
 059            uri.AppendPath("/connectionMonitors/", false);
 060            uri.AppendPath(connectionMonitorName, true);
 061            uri.AppendQuery("api-version", "2020-04-01", true);
 062            request.Uri = uri;
 063            request.Headers.Add("Content-Type", "application/json");
 064            var content = new Utf8JsonRequestContent();
 065            content.JsonWriter.WriteObjectValue(parameters);
 066            request.Content = content;
 067            return message;
 68        }
 69
 70        /// <summary> Create or update a connection monitor. </summary>
 71        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 72        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 73        /// <param name="connectionMonitorName"> The name of the connection monitor. </param>
 74        /// <param name="parameters"> Parameters that define the operation to create a connection monitor. </param>
 75        /// <param name="cancellationToken"> The cancellation token to use. </param>
 76        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string networkWatcherName, string conn
 77        {
 078            if (resourceGroupName == null)
 79            {
 080                throw new ArgumentNullException(nameof(resourceGroupName));
 81            }
 082            if (networkWatcherName == null)
 83            {
 084                throw new ArgumentNullException(nameof(networkWatcherName));
 85            }
 086            if (connectionMonitorName == null)
 87            {
 088                throw new ArgumentNullException(nameof(connectionMonitorName));
 89            }
 090            if (parameters == null)
 91            {
 092                throw new ArgumentNullException(nameof(parameters));
 93            }
 94
 095            using var message = CreateCreateOrUpdateRequest(resourceGroupName, networkWatcherName, connectionMonitorName
 096            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 097            switch (message.Response.Status)
 98            {
 99                case 200:
 100                case 201:
 0101                    return message.Response;
 102                default:
 0103                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 104            }
 0105        }
 106
 107        /// <summary> Create or update a connection monitor. </summary>
 108        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 109        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 110        /// <param name="connectionMonitorName"> The name of the connection monitor. </param>
 111        /// <param name="parameters"> Parameters that define the operation to create a connection monitor. </param>
 112        /// <param name="cancellationToken"> The cancellation token to use. </param>
 113        public Response CreateOrUpdate(string resourceGroupName, string networkWatcherName, string connectionMonitorName
 114        {
 0115            if (resourceGroupName == null)
 116            {
 0117                throw new ArgumentNullException(nameof(resourceGroupName));
 118            }
 0119            if (networkWatcherName == null)
 120            {
 0121                throw new ArgumentNullException(nameof(networkWatcherName));
 122            }
 0123            if (connectionMonitorName == null)
 124            {
 0125                throw new ArgumentNullException(nameof(connectionMonitorName));
 126            }
 0127            if (parameters == null)
 128            {
 0129                throw new ArgumentNullException(nameof(parameters));
 130            }
 131
 0132            using var message = CreateCreateOrUpdateRequest(resourceGroupName, networkWatcherName, connectionMonitorName
 0133            _pipeline.Send(message, cancellationToken);
 0134            switch (message.Response.Status)
 135            {
 136                case 200:
 137                case 201:
 0138                    return message.Response;
 139                default:
 0140                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 141            }
 0142        }
 143
 144        internal HttpMessage CreateGetRequest(string resourceGroupName, string networkWatcherName, string connectionMoni
 145        {
 0146            var message = _pipeline.CreateMessage();
 0147            var request = message.Request;
 0148            request.Method = RequestMethod.Get;
 0149            var uri = new RawRequestUriBuilder();
 0150            uri.Reset(endpoint);
 0151            uri.AppendPath("/subscriptions/", false);
 0152            uri.AppendPath(subscriptionId, true);
 0153            uri.AppendPath("/resourceGroups/", false);
 0154            uri.AppendPath(resourceGroupName, true);
 0155            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 0156            uri.AppendPath(networkWatcherName, true);
 0157            uri.AppendPath("/connectionMonitors/", false);
 0158            uri.AppendPath(connectionMonitorName, true);
 0159            uri.AppendQuery("api-version", "2020-04-01", true);
 0160            request.Uri = uri;
 0161            return message;
 162        }
 163
 164        /// <summary> Gets a connection monitor by name. </summary>
 165        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 166        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 167        /// <param name="connectionMonitorName"> The name of the connection monitor. </param>
 168        /// <param name="cancellationToken"> The cancellation token to use. </param>
 169        public async Task<Response<ConnectionMonitorResult>> GetAsync(string resourceGroupName, string networkWatcherNam
 170        {
 0171            if (resourceGroupName == null)
 172            {
 0173                throw new ArgumentNullException(nameof(resourceGroupName));
 174            }
 0175            if (networkWatcherName == null)
 176            {
 0177                throw new ArgumentNullException(nameof(networkWatcherName));
 178            }
 0179            if (connectionMonitorName == null)
 180            {
 0181                throw new ArgumentNullException(nameof(connectionMonitorName));
 182            }
 183
 0184            using var message = CreateGetRequest(resourceGroupName, networkWatcherName, connectionMonitorName);
 0185            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0186            switch (message.Response.Status)
 187            {
 188                case 200:
 189                    {
 0190                        ConnectionMonitorResult value = default;
 0191                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0192                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 193                        {
 0194                            value = null;
 195                        }
 196                        else
 197                        {
 0198                            value = ConnectionMonitorResult.DeserializeConnectionMonitorResult(document.RootElement);
 199                        }
 0200                        return Response.FromValue(value, message.Response);
 201                    }
 202                default:
 0203                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 204            }
 0205        }
 206
 207        /// <summary> Gets a connection monitor by name. </summary>
 208        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 209        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 210        /// <param name="connectionMonitorName"> The name of the connection monitor. </param>
 211        /// <param name="cancellationToken"> The cancellation token to use. </param>
 212        public Response<ConnectionMonitorResult> Get(string resourceGroupName, string networkWatcherName, string connect
 213        {
 0214            if (resourceGroupName == null)
 215            {
 0216                throw new ArgumentNullException(nameof(resourceGroupName));
 217            }
 0218            if (networkWatcherName == null)
 219            {
 0220                throw new ArgumentNullException(nameof(networkWatcherName));
 221            }
 0222            if (connectionMonitorName == null)
 223            {
 0224                throw new ArgumentNullException(nameof(connectionMonitorName));
 225            }
 226
 0227            using var message = CreateGetRequest(resourceGroupName, networkWatcherName, connectionMonitorName);
 0228            _pipeline.Send(message, cancellationToken);
 0229            switch (message.Response.Status)
 230            {
 231                case 200:
 232                    {
 0233                        ConnectionMonitorResult value = default;
 0234                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0235                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 236                        {
 0237                            value = null;
 238                        }
 239                        else
 240                        {
 0241                            value = ConnectionMonitorResult.DeserializeConnectionMonitorResult(document.RootElement);
 242                        }
 0243                        return Response.FromValue(value, message.Response);
 244                    }
 245                default:
 0246                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 247            }
 0248        }
 249
 250        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string networkWatcherName, string connectionM
 251        {
 0252            var message = _pipeline.CreateMessage();
 0253            var request = message.Request;
 0254            request.Method = RequestMethod.Delete;
 0255            var uri = new RawRequestUriBuilder();
 0256            uri.Reset(endpoint);
 0257            uri.AppendPath("/subscriptions/", false);
 0258            uri.AppendPath(subscriptionId, true);
 0259            uri.AppendPath("/resourceGroups/", false);
 0260            uri.AppendPath(resourceGroupName, true);
 0261            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 0262            uri.AppendPath(networkWatcherName, true);
 0263            uri.AppendPath("/connectionMonitors/", false);
 0264            uri.AppendPath(connectionMonitorName, true);
 0265            uri.AppendQuery("api-version", "2020-04-01", true);
 0266            request.Uri = uri;
 0267            return message;
 268        }
 269
 270        /// <summary> Deletes the specified connection monitor. </summary>
 271        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 272        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 273        /// <param name="connectionMonitorName"> The name of the connection monitor. </param>
 274        /// <param name="cancellationToken"> The cancellation token to use. </param>
 275        public async Task<Response> DeleteAsync(string resourceGroupName, string networkWatcherName, string connectionMo
 276        {
 0277            if (resourceGroupName == null)
 278            {
 0279                throw new ArgumentNullException(nameof(resourceGroupName));
 280            }
 0281            if (networkWatcherName == null)
 282            {
 0283                throw new ArgumentNullException(nameof(networkWatcherName));
 284            }
 0285            if (connectionMonitorName == null)
 286            {
 0287                throw new ArgumentNullException(nameof(connectionMonitorName));
 288            }
 289
 0290            using var message = CreateDeleteRequest(resourceGroupName, networkWatcherName, connectionMonitorName);
 0291            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0292            switch (message.Response.Status)
 293            {
 294                case 202:
 295                case 204:
 0296                    return message.Response;
 297                default:
 0298                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 299            }
 0300        }
 301
 302        /// <summary> Deletes the specified connection monitor. </summary>
 303        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 304        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 305        /// <param name="connectionMonitorName"> The name of the connection monitor. </param>
 306        /// <param name="cancellationToken"> The cancellation token to use. </param>
 307        public Response Delete(string resourceGroupName, string networkWatcherName, string connectionMonitorName, Cancel
 308        {
 0309            if (resourceGroupName == null)
 310            {
 0311                throw new ArgumentNullException(nameof(resourceGroupName));
 312            }
 0313            if (networkWatcherName == null)
 314            {
 0315                throw new ArgumentNullException(nameof(networkWatcherName));
 316            }
 0317            if (connectionMonitorName == null)
 318            {
 0319                throw new ArgumentNullException(nameof(connectionMonitorName));
 320            }
 321
 0322            using var message = CreateDeleteRequest(resourceGroupName, networkWatcherName, connectionMonitorName);
 0323            _pipeline.Send(message, cancellationToken);
 0324            switch (message.Response.Status)
 325            {
 326                case 202:
 327                case 204:
 0328                    return message.Response;
 329                default:
 0330                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 331            }
 0332        }
 333
 334        internal HttpMessage CreateUpdateTagsRequest(string resourceGroupName, string networkWatcherName, string connect
 335        {
 0336            var message = _pipeline.CreateMessage();
 0337            var request = message.Request;
 0338            request.Method = RequestMethod.Patch;
 0339            var uri = new RawRequestUriBuilder();
 0340            uri.Reset(endpoint);
 0341            uri.AppendPath("/subscriptions/", false);
 0342            uri.AppendPath(subscriptionId, true);
 0343            uri.AppendPath("/resourceGroups/", false);
 0344            uri.AppendPath(resourceGroupName, true);
 0345            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 0346            uri.AppendPath(networkWatcherName, true);
 0347            uri.AppendPath("/connectionMonitors/", false);
 0348            uri.AppendPath(connectionMonitorName, true);
 0349            uri.AppendQuery("api-version", "2020-04-01", true);
 0350            request.Uri = uri;
 0351            request.Headers.Add("Content-Type", "application/json");
 0352            var content = new Utf8JsonRequestContent();
 0353            content.JsonWriter.WriteObjectValue(parameters);
 0354            request.Content = content;
 0355            return message;
 356        }
 357
 358        /// <summary> Update tags of the specified connection monitor. </summary>
 359        /// <param name="resourceGroupName"> The name of the resource group. </param>
 360        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 361        /// <param name="connectionMonitorName"> The name of the connection monitor. </param>
 362        /// <param name="parameters"> Parameters supplied to update connection monitor tags. </param>
 363        /// <param name="cancellationToken"> The cancellation token to use. </param>
 364        public async Task<Response<ConnectionMonitorResult>> UpdateTagsAsync(string resourceGroupName, string networkWat
 365        {
 0366            if (resourceGroupName == null)
 367            {
 0368                throw new ArgumentNullException(nameof(resourceGroupName));
 369            }
 0370            if (networkWatcherName == null)
 371            {
 0372                throw new ArgumentNullException(nameof(networkWatcherName));
 373            }
 0374            if (connectionMonitorName == null)
 375            {
 0376                throw new ArgumentNullException(nameof(connectionMonitorName));
 377            }
 0378            if (parameters == null)
 379            {
 0380                throw new ArgumentNullException(nameof(parameters));
 381            }
 382
 0383            using var message = CreateUpdateTagsRequest(resourceGroupName, networkWatcherName, connectionMonitorName, pa
 0384            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0385            switch (message.Response.Status)
 386            {
 387                case 200:
 388                    {
 0389                        ConnectionMonitorResult value = default;
 0390                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0391                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 392                        {
 0393                            value = null;
 394                        }
 395                        else
 396                        {
 0397                            value = ConnectionMonitorResult.DeserializeConnectionMonitorResult(document.RootElement);
 398                        }
 0399                        return Response.FromValue(value, message.Response);
 400                    }
 401                default:
 0402                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 403            }
 0404        }
 405
 406        /// <summary> Update tags of the specified connection monitor. </summary>
 407        /// <param name="resourceGroupName"> The name of the resource group. </param>
 408        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 409        /// <param name="connectionMonitorName"> The name of the connection monitor. </param>
 410        /// <param name="parameters"> Parameters supplied to update connection monitor tags. </param>
 411        /// <param name="cancellationToken"> The cancellation token to use. </param>
 412        public Response<ConnectionMonitorResult> UpdateTags(string resourceGroupName, string networkWatcherName, string 
 413        {
 0414            if (resourceGroupName == null)
 415            {
 0416                throw new ArgumentNullException(nameof(resourceGroupName));
 417            }
 0418            if (networkWatcherName == null)
 419            {
 0420                throw new ArgumentNullException(nameof(networkWatcherName));
 421            }
 0422            if (connectionMonitorName == null)
 423            {
 0424                throw new ArgumentNullException(nameof(connectionMonitorName));
 425            }
 0426            if (parameters == null)
 427            {
 0428                throw new ArgumentNullException(nameof(parameters));
 429            }
 430
 0431            using var message = CreateUpdateTagsRequest(resourceGroupName, networkWatcherName, connectionMonitorName, pa
 0432            _pipeline.Send(message, cancellationToken);
 0433            switch (message.Response.Status)
 434            {
 435                case 200:
 436                    {
 0437                        ConnectionMonitorResult value = default;
 0438                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0439                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 440                        {
 0441                            value = null;
 442                        }
 443                        else
 444                        {
 0445                            value = ConnectionMonitorResult.DeserializeConnectionMonitorResult(document.RootElement);
 446                        }
 0447                        return Response.FromValue(value, message.Response);
 448                    }
 449                default:
 0450                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 451            }
 0452        }
 453
 454        internal HttpMessage CreateStopRequest(string resourceGroupName, string networkWatcherName, string connectionMon
 455        {
 0456            var message = _pipeline.CreateMessage();
 0457            var request = message.Request;
 0458            request.Method = RequestMethod.Post;
 0459            var uri = new RawRequestUriBuilder();
 0460            uri.Reset(endpoint);
 0461            uri.AppendPath("/subscriptions/", false);
 0462            uri.AppendPath(subscriptionId, true);
 0463            uri.AppendPath("/resourceGroups/", false);
 0464            uri.AppendPath(resourceGroupName, true);
 0465            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 0466            uri.AppendPath(networkWatcherName, true);
 0467            uri.AppendPath("/connectionMonitors/", false);
 0468            uri.AppendPath(connectionMonitorName, true);
 0469            uri.AppendPath("/stop", false);
 0470            uri.AppendQuery("api-version", "2020-04-01", true);
 0471            request.Uri = uri;
 0472            return message;
 473        }
 474
 475        /// <summary> Stops the specified connection monitor. </summary>
 476        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 477        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 478        /// <param name="connectionMonitorName"> The name of the connection monitor. </param>
 479        /// <param name="cancellationToken"> The cancellation token to use. </param>
 480        public async Task<Response> StopAsync(string resourceGroupName, string networkWatcherName, string connectionMoni
 481        {
 0482            if (resourceGroupName == null)
 483            {
 0484                throw new ArgumentNullException(nameof(resourceGroupName));
 485            }
 0486            if (networkWatcherName == null)
 487            {
 0488                throw new ArgumentNullException(nameof(networkWatcherName));
 489            }
 0490            if (connectionMonitorName == null)
 491            {
 0492                throw new ArgumentNullException(nameof(connectionMonitorName));
 493            }
 494
 0495            using var message = CreateStopRequest(resourceGroupName, networkWatcherName, connectionMonitorName);
 0496            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0497            switch (message.Response.Status)
 498            {
 499                case 200:
 500                case 202:
 0501                    return message.Response;
 502                default:
 0503                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 504            }
 0505        }
 506
 507        /// <summary> Stops the specified connection monitor. </summary>
 508        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 509        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 510        /// <param name="connectionMonitorName"> The name of the connection monitor. </param>
 511        /// <param name="cancellationToken"> The cancellation token to use. </param>
 512        public Response Stop(string resourceGroupName, string networkWatcherName, string connectionMonitorName, Cancella
 513        {
 0514            if (resourceGroupName == null)
 515            {
 0516                throw new ArgumentNullException(nameof(resourceGroupName));
 517            }
 0518            if (networkWatcherName == null)
 519            {
 0520                throw new ArgumentNullException(nameof(networkWatcherName));
 521            }
 0522            if (connectionMonitorName == null)
 523            {
 0524                throw new ArgumentNullException(nameof(connectionMonitorName));
 525            }
 526
 0527            using var message = CreateStopRequest(resourceGroupName, networkWatcherName, connectionMonitorName);
 0528            _pipeline.Send(message, cancellationToken);
 0529            switch (message.Response.Status)
 530            {
 531                case 200:
 532                case 202:
 0533                    return message.Response;
 534                default:
 0535                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 536            }
 0537        }
 538
 539        internal HttpMessage CreateStartRequest(string resourceGroupName, string networkWatcherName, string connectionMo
 540        {
 0541            var message = _pipeline.CreateMessage();
 0542            var request = message.Request;
 0543            request.Method = RequestMethod.Post;
 0544            var uri = new RawRequestUriBuilder();
 0545            uri.Reset(endpoint);
 0546            uri.AppendPath("/subscriptions/", false);
 0547            uri.AppendPath(subscriptionId, true);
 0548            uri.AppendPath("/resourceGroups/", false);
 0549            uri.AppendPath(resourceGroupName, true);
 0550            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 0551            uri.AppendPath(networkWatcherName, true);
 0552            uri.AppendPath("/connectionMonitors/", false);
 0553            uri.AppendPath(connectionMonitorName, true);
 0554            uri.AppendPath("/start", false);
 0555            uri.AppendQuery("api-version", "2020-04-01", true);
 0556            request.Uri = uri;
 0557            return message;
 558        }
 559
 560        /// <summary> Starts the specified connection monitor. </summary>
 561        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 562        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 563        /// <param name="connectionMonitorName"> The name of the connection monitor. </param>
 564        /// <param name="cancellationToken"> The cancellation token to use. </param>
 565        public async Task<Response> StartAsync(string resourceGroupName, string networkWatcherName, string connectionMon
 566        {
 0567            if (resourceGroupName == null)
 568            {
 0569                throw new ArgumentNullException(nameof(resourceGroupName));
 570            }
 0571            if (networkWatcherName == null)
 572            {
 0573                throw new ArgumentNullException(nameof(networkWatcherName));
 574            }
 0575            if (connectionMonitorName == null)
 576            {
 0577                throw new ArgumentNullException(nameof(connectionMonitorName));
 578            }
 579
 0580            using var message = CreateStartRequest(resourceGroupName, networkWatcherName, connectionMonitorName);
 0581            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0582            switch (message.Response.Status)
 583            {
 584                case 200:
 585                case 202:
 0586                    return message.Response;
 587                default:
 0588                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 589            }
 0590        }
 591
 592        /// <summary> Starts the specified connection monitor. </summary>
 593        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 594        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 595        /// <param name="connectionMonitorName"> The name of the connection monitor. </param>
 596        /// <param name="cancellationToken"> The cancellation token to use. </param>
 597        public Response Start(string resourceGroupName, string networkWatcherName, string connectionMonitorName, Cancell
 598        {
 0599            if (resourceGroupName == null)
 600            {
 0601                throw new ArgumentNullException(nameof(resourceGroupName));
 602            }
 0603            if (networkWatcherName == null)
 604            {
 0605                throw new ArgumentNullException(nameof(networkWatcherName));
 606            }
 0607            if (connectionMonitorName == null)
 608            {
 0609                throw new ArgumentNullException(nameof(connectionMonitorName));
 610            }
 611
 0612            using var message = CreateStartRequest(resourceGroupName, networkWatcherName, connectionMonitorName);
 0613            _pipeline.Send(message, cancellationToken);
 0614            switch (message.Response.Status)
 615            {
 616                case 200:
 617                case 202:
 0618                    return message.Response;
 619                default:
 0620                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 621            }
 0622        }
 623
 624        internal HttpMessage CreateQueryRequest(string resourceGroupName, string networkWatcherName, string connectionMo
 625        {
 0626            var message = _pipeline.CreateMessage();
 0627            var request = message.Request;
 0628            request.Method = RequestMethod.Post;
 0629            var uri = new RawRequestUriBuilder();
 0630            uri.Reset(endpoint);
 0631            uri.AppendPath("/subscriptions/", false);
 0632            uri.AppendPath(subscriptionId, true);
 0633            uri.AppendPath("/resourceGroups/", false);
 0634            uri.AppendPath(resourceGroupName, true);
 0635            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 0636            uri.AppendPath(networkWatcherName, true);
 0637            uri.AppendPath("/connectionMonitors/", false);
 0638            uri.AppendPath(connectionMonitorName, true);
 0639            uri.AppendPath("/query", false);
 0640            uri.AppendQuery("api-version", "2020-04-01", true);
 0641            request.Uri = uri;
 0642            return message;
 643        }
 644
 645        /// <summary> Query a snapshot of the most recent connection states. </summary>
 646        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 647        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 648        /// <param name="connectionMonitorName"> The name given to the connection monitor. </param>
 649        /// <param name="cancellationToken"> The cancellation token to use. </param>
 650        public async Task<Response> QueryAsync(string resourceGroupName, string networkWatcherName, string connectionMon
 651        {
 0652            if (resourceGroupName == null)
 653            {
 0654                throw new ArgumentNullException(nameof(resourceGroupName));
 655            }
 0656            if (networkWatcherName == null)
 657            {
 0658                throw new ArgumentNullException(nameof(networkWatcherName));
 659            }
 0660            if (connectionMonitorName == null)
 661            {
 0662                throw new ArgumentNullException(nameof(connectionMonitorName));
 663            }
 664
 0665            using var message = CreateQueryRequest(resourceGroupName, networkWatcherName, connectionMonitorName);
 0666            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0667            switch (message.Response.Status)
 668            {
 669                case 200:
 670                case 202:
 0671                    return message.Response;
 672                default:
 0673                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 674            }
 0675        }
 676
 677        /// <summary> Query a snapshot of the most recent connection states. </summary>
 678        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 679        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 680        /// <param name="connectionMonitorName"> The name given to the connection monitor. </param>
 681        /// <param name="cancellationToken"> The cancellation token to use. </param>
 682        public Response Query(string resourceGroupName, string networkWatcherName, string connectionMonitorName, Cancell
 683        {
 0684            if (resourceGroupName == null)
 685            {
 0686                throw new ArgumentNullException(nameof(resourceGroupName));
 687            }
 0688            if (networkWatcherName == null)
 689            {
 0690                throw new ArgumentNullException(nameof(networkWatcherName));
 691            }
 0692            if (connectionMonitorName == null)
 693            {
 0694                throw new ArgumentNullException(nameof(connectionMonitorName));
 695            }
 696
 0697            using var message = CreateQueryRequest(resourceGroupName, networkWatcherName, connectionMonitorName);
 0698            _pipeline.Send(message, cancellationToken);
 0699            switch (message.Response.Status)
 700            {
 701                case 200:
 702                case 202:
 0703                    return message.Response;
 704                default:
 0705                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 706            }
 0707        }
 708
 709        internal HttpMessage CreateListRequest(string resourceGroupName, string networkWatcherName)
 710        {
 0711            var message = _pipeline.CreateMessage();
 0712            var request = message.Request;
 0713            request.Method = RequestMethod.Get;
 0714            var uri = new RawRequestUriBuilder();
 0715            uri.Reset(endpoint);
 0716            uri.AppendPath("/subscriptions/", false);
 0717            uri.AppendPath(subscriptionId, true);
 0718            uri.AppendPath("/resourceGroups/", false);
 0719            uri.AppendPath(resourceGroupName, true);
 0720            uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false);
 0721            uri.AppendPath(networkWatcherName, true);
 0722            uri.AppendPath("/connectionMonitors", false);
 0723            uri.AppendQuery("api-version", "2020-04-01", true);
 0724            request.Uri = uri;
 0725            return message;
 726        }
 727
 728        /// <summary> Lists all connection monitors for the specified Network Watcher. </summary>
 729        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 730        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 731        /// <param name="cancellationToken"> The cancellation token to use. </param>
 732        public async Task<Response<ConnectionMonitorListResult>> ListAsync(string resourceGroupName, string networkWatch
 733        {
 0734            if (resourceGroupName == null)
 735            {
 0736                throw new ArgumentNullException(nameof(resourceGroupName));
 737            }
 0738            if (networkWatcherName == null)
 739            {
 0740                throw new ArgumentNullException(nameof(networkWatcherName));
 741            }
 742
 0743            using var message = CreateListRequest(resourceGroupName, networkWatcherName);
 0744            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0745            switch (message.Response.Status)
 746            {
 747                case 200:
 748                    {
 0749                        ConnectionMonitorListResult value = default;
 0750                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0751                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 752                        {
 0753                            value = null;
 754                        }
 755                        else
 756                        {
 0757                            value = ConnectionMonitorListResult.DeserializeConnectionMonitorListResult(document.RootElem
 758                        }
 0759                        return Response.FromValue(value, message.Response);
 760                    }
 761                default:
 0762                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 763            }
 0764        }
 765
 766        /// <summary> Lists all connection monitors for the specified Network Watcher. </summary>
 767        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 768        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 769        /// <param name="cancellationToken"> The cancellation token to use. </param>
 770        public Response<ConnectionMonitorListResult> List(string resourceGroupName, string networkWatcherName, Cancellat
 771        {
 0772            if (resourceGroupName == null)
 773            {
 0774                throw new ArgumentNullException(nameof(resourceGroupName));
 775            }
 0776            if (networkWatcherName == null)
 777            {
 0778                throw new ArgumentNullException(nameof(networkWatcherName));
 779            }
 780
 0781            using var message = CreateListRequest(resourceGroupName, networkWatcherName);
 0782            _pipeline.Send(message, cancellationToken);
 0783            switch (message.Response.Status)
 784            {
 785                case 200:
 786                    {
 0787                        ConnectionMonitorListResult value = default;
 0788                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0789                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 790                        {
 0791                            value = null;
 792                        }
 793                        else
 794                        {
 0795                            value = ConnectionMonitorListResult.DeserializeConnectionMonitorListResult(document.RootElem
 796                        }
 0797                        return Response.FromValue(value, message.Response);
 798                    }
 799                default:
 0800                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 801            }
 0802        }
 803    }
 804}