< Summary

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

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%
CreateListRequest(...)-0%100%
ListAsync()-0%0%
List(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\FlowLogsRestOperations.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 FlowLogsRestOperations
 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 FlowLogsRestOperations. </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 FlowLogsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId,
 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 flo
 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("/flowLogs/", false);
 060            uri.AppendPath(flowLogName, 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 flow log for the specified network security group. </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="flowLogName"> The name of the flow log. </param>
 74        /// <param name="parameters"> Parameters that define the create or update flow log resource. </param>
 75        /// <param name="cancellationToken"> The cancellation token to use. </param>
 76        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string networkWatcherName, string flow
 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 (flowLogName == null)
 87            {
 088                throw new ArgumentNullException(nameof(flowLogName));
 89            }
 090            if (parameters == null)
 91            {
 092                throw new ArgumentNullException(nameof(parameters));
 93            }
 94
 095            using var message = CreateCreateOrUpdateRequest(resourceGroupName, networkWatcherName, flowLogName, paramete
 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 flow log for the specified network security group. </summary>
 108        /// <param name="resourceGroupName"> The name of the resource group. </param>
 109        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 110        /// <param name="flowLogName"> The name of the flow log. </param>
 111        /// <param name="parameters"> Parameters that define the create or update flow log resource. </param>
 112        /// <param name="cancellationToken"> The cancellation token to use. </param>
 113        public Response CreateOrUpdate(string resourceGroupName, string networkWatcherName, string flowLogName, FlowLog 
 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 (flowLogName == null)
 124            {
 0125                throw new ArgumentNullException(nameof(flowLogName));
 126            }
 0127            if (parameters == null)
 128            {
 0129                throw new ArgumentNullException(nameof(parameters));
 130            }
 131
 0132            using var message = CreateCreateOrUpdateRequest(resourceGroupName, networkWatcherName, flowLogName, paramete
 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 flowLogName)
 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("/flowLogs/", false);
 0158            uri.AppendPath(flowLogName, true);
 0159            uri.AppendQuery("api-version", "2020-04-01", true);
 0160            request.Uri = uri;
 0161            return message;
 162        }
 163
 164        /// <summary> Gets a flow log resource by name. </summary>
 165        /// <param name="resourceGroupName"> The name of the resource group. </param>
 166        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 167        /// <param name="flowLogName"> The name of the flow log resource. </param>
 168        /// <param name="cancellationToken"> The cancellation token to use. </param>
 169        public async Task<Response<FlowLog>> GetAsync(string resourceGroupName, string networkWatcherName, string flowLo
 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 (flowLogName == null)
 180            {
 0181                throw new ArgumentNullException(nameof(flowLogName));
 182            }
 183
 0184            using var message = CreateGetRequest(resourceGroupName, networkWatcherName, flowLogName);
 0185            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0186            switch (message.Response.Status)
 187            {
 188                case 200:
 189                    {
 0190                        FlowLog 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 = FlowLog.DeserializeFlowLog(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 flow log resource by name. </summary>
 208        /// <param name="resourceGroupName"> The name of the resource group. </param>
 209        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 210        /// <param name="flowLogName"> The name of the flow log resource. </param>
 211        /// <param name="cancellationToken"> The cancellation token to use. </param>
 212        public Response<FlowLog> Get(string resourceGroupName, string networkWatcherName, string flowLogName, Cancellati
 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 (flowLogName == null)
 223            {
 0224                throw new ArgumentNullException(nameof(flowLogName));
 225            }
 226
 0227            using var message = CreateGetRequest(resourceGroupName, networkWatcherName, flowLogName);
 0228            _pipeline.Send(message, cancellationToken);
 0229            switch (message.Response.Status)
 230            {
 231                case 200:
 232                    {
 0233                        FlowLog 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 = FlowLog.DeserializeFlowLog(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 flowLogName
 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("/flowLogs/", false);
 0264            uri.AppendPath(flowLogName, true);
 0265            uri.AppendQuery("api-version", "2020-04-01", true);
 0266            request.Uri = uri;
 0267            return message;
 268        }
 269
 270        /// <summary> Deletes the specified flow log resource. </summary>
 271        /// <param name="resourceGroupName"> The name of the resource group. </param>
 272        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 273        /// <param name="flowLogName"> The name of the flow log resource. </param>
 274        /// <param name="cancellationToken"> The cancellation token to use. </param>
 275        public async Task<Response> DeleteAsync(string resourceGroupName, string networkWatcherName, string flowLogName,
 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 (flowLogName == null)
 286            {
 0287                throw new ArgumentNullException(nameof(flowLogName));
 288            }
 289
 0290            using var message = CreateDeleteRequest(resourceGroupName, networkWatcherName, flowLogName);
 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 flow log resource. </summary>
 303        /// <param name="resourceGroupName"> The name of the resource group. </param>
 304        /// <param name="networkWatcherName"> The name of the network watcher. </param>
 305        /// <param name="flowLogName"> The name of the flow log resource. </param>
 306        /// <param name="cancellationToken"> The cancellation token to use. </param>
 307        public Response Delete(string resourceGroupName, string networkWatcherName, string flowLogName, CancellationToke
 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 (flowLogName == null)
 318            {
 0319                throw new ArgumentNullException(nameof(flowLogName));
 320            }
 321
 0322            using var message = CreateDeleteRequest(resourceGroupName, networkWatcherName, flowLogName);
 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 CreateListRequest(string resourceGroupName, string networkWatcherName)
 335        {
 0336            var message = _pipeline.CreateMessage();
 0337            var request = message.Request;
 0338            request.Method = RequestMethod.Get;
 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("/flowLogs", false);
 0348            uri.AppendQuery("api-version", "2020-04-01", true);
 0349            request.Uri = uri;
 0350            return message;
 351        }
 352
 353        /// <summary> Lists all flow log resources for the specified Network Watcher. </summary>
 354        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 355        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 356        /// <param name="cancellationToken"> The cancellation token to use. </param>
 357        public async Task<Response<FlowLogListResult>> ListAsync(string resourceGroupName, string networkWatcherName, Ca
 358        {
 0359            if (resourceGroupName == null)
 360            {
 0361                throw new ArgumentNullException(nameof(resourceGroupName));
 362            }
 0363            if (networkWatcherName == null)
 364            {
 0365                throw new ArgumentNullException(nameof(networkWatcherName));
 366            }
 367
 0368            using var message = CreateListRequest(resourceGroupName, networkWatcherName);
 0369            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0370            switch (message.Response.Status)
 371            {
 372                case 200:
 373                    {
 0374                        FlowLogListResult value = default;
 0375                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0376                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 377                        {
 0378                            value = null;
 379                        }
 380                        else
 381                        {
 0382                            value = FlowLogListResult.DeserializeFlowLogListResult(document.RootElement);
 383                        }
 0384                        return Response.FromValue(value, message.Response);
 385                    }
 386                default:
 0387                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 388            }
 0389        }
 390
 391        /// <summary> Lists all flow log resources for the specified Network Watcher. </summary>
 392        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 393        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 394        /// <param name="cancellationToken"> The cancellation token to use. </param>
 395        public Response<FlowLogListResult> List(string resourceGroupName, string networkWatcherName, CancellationToken c
 396        {
 0397            if (resourceGroupName == null)
 398            {
 0399                throw new ArgumentNullException(nameof(resourceGroupName));
 400            }
 0401            if (networkWatcherName == null)
 402            {
 0403                throw new ArgumentNullException(nameof(networkWatcherName));
 404            }
 405
 0406            using var message = CreateListRequest(resourceGroupName, networkWatcherName);
 0407            _pipeline.Send(message, cancellationToken);
 0408            switch (message.Response.Status)
 409            {
 410                case 200:
 411                    {
 0412                        FlowLogListResult value = default;
 0413                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0414                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 415                        {
 0416                            value = null;
 417                        }
 418                        else
 419                        {
 0420                            value = FlowLogListResult.DeserializeFlowLogListResult(document.RootElement);
 421                        }
 0422                        return Response.FromValue(value, message.Response);
 423                    }
 424                default:
 0425                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 426            }
 0427        }
 428
 429        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string networkWatcherN
 430        {
 0431            var message = _pipeline.CreateMessage();
 0432            var request = message.Request;
 0433            request.Method = RequestMethod.Get;
 0434            var uri = new RawRequestUriBuilder();
 0435            uri.Reset(endpoint);
 0436            uri.AppendRawNextLink(nextLink, false);
 0437            request.Uri = uri;
 0438            return message;
 439        }
 440
 441        /// <summary> Lists all flow log resources for the specified Network Watcher. </summary>
 442        /// <param name="nextLink"> The URL to the next page of results. </param>
 443        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 444        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 445        /// <param name="cancellationToken"> The cancellation token to use. </param>
 446        public async Task<Response<FlowLogListResult>> ListNextPageAsync(string nextLink, string resourceGroupName, stri
 447        {
 0448            if (nextLink == null)
 449            {
 0450                throw new ArgumentNullException(nameof(nextLink));
 451            }
 0452            if (resourceGroupName == null)
 453            {
 0454                throw new ArgumentNullException(nameof(resourceGroupName));
 455            }
 0456            if (networkWatcherName == null)
 457            {
 0458                throw new ArgumentNullException(nameof(networkWatcherName));
 459            }
 460
 0461            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, networkWatcherName);
 0462            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0463            switch (message.Response.Status)
 464            {
 465                case 200:
 466                    {
 0467                        FlowLogListResult value = default;
 0468                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0469                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 470                        {
 0471                            value = null;
 472                        }
 473                        else
 474                        {
 0475                            value = FlowLogListResult.DeserializeFlowLogListResult(document.RootElement);
 476                        }
 0477                        return Response.FromValue(value, message.Response);
 478                    }
 479                default:
 0480                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 481            }
 0482        }
 483
 484        /// <summary> Lists all flow log resources for the specified Network Watcher. </summary>
 485        /// <param name="nextLink"> The URL to the next page of results. </param>
 486        /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param>
 487        /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param>
 488        /// <param name="cancellationToken"> The cancellation token to use. </param>
 489        public Response<FlowLogListResult> ListNextPage(string nextLink, string resourceGroupName, string networkWatcher
 490        {
 0491            if (nextLink == null)
 492            {
 0493                throw new ArgumentNullException(nameof(nextLink));
 494            }
 0495            if (resourceGroupName == null)
 496            {
 0497                throw new ArgumentNullException(nameof(resourceGroupName));
 498            }
 0499            if (networkWatcherName == null)
 500            {
 0501                throw new ArgumentNullException(nameof(networkWatcherName));
 502            }
 503
 0504            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, networkWatcherName);
 0505            _pipeline.Send(message, cancellationToken);
 0506            switch (message.Response.Status)
 507            {
 508                case 200:
 509                    {
 0510                        FlowLogListResult value = default;
 0511                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0512                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 513                        {
 0514                            value = null;
 515                        }
 516                        else
 517                        {
 0518                            value = FlowLogListResult.DeserializeFlowLogListResult(document.RootElement);
 519                        }
 0520                        return Response.FromValue(value, message.Response);
 521                    }
 522                default:
 0523                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 524            }
 0525        }
 526    }
 527}