< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-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\AvailableDelegationsRestOperations.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 AvailableDelegationsRestOperations
 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 AvailableDelegationsRestOperations. </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 AvailableDelegationsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string sub
 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 CreateListRequest(string location)
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Get;
 051            var uri = new RawRequestUriBuilder();
 052            uri.Reset(endpoint);
 053            uri.AppendPath("/subscriptions/", false);
 054            uri.AppendPath(subscriptionId, true);
 055            uri.AppendPath("/providers/Microsoft.Network/locations/", false);
 056            uri.AppendPath(location, true);
 057            uri.AppendPath("/availableDelegations", false);
 058            uri.AppendQuery("api-version", "2020-04-01", true);
 059            request.Uri = uri;
 060            return message;
 61        }
 62
 63        /// <summary> Gets all of the available subnet delegations for this subscription in this region. </summary>
 64        /// <param name="location"> The location of the subnet. </param>
 65        /// <param name="cancellationToken"> The cancellation token to use. </param>
 66        public async Task<Response<AvailableDelegationsResult>> ListAsync(string location, CancellationToken cancellatio
 67        {
 068            if (location == null)
 69            {
 070                throw new ArgumentNullException(nameof(location));
 71            }
 72
 073            using var message = CreateListRequest(location);
 074            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 075            switch (message.Response.Status)
 76            {
 77                case 200:
 78                    {
 079                        AvailableDelegationsResult value = default;
 080                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 081                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 82                        {
 083                            value = null;
 84                        }
 85                        else
 86                        {
 087                            value = AvailableDelegationsResult.DeserializeAvailableDelegationsResult(document.RootElemen
 88                        }
 089                        return Response.FromValue(value, message.Response);
 90                    }
 91                default:
 092                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 93            }
 094        }
 95
 96        /// <summary> Gets all of the available subnet delegations for this subscription in this region. </summary>
 97        /// <param name="location"> The location of the subnet. </param>
 98        /// <param name="cancellationToken"> The cancellation token to use. </param>
 99        public Response<AvailableDelegationsResult> List(string location, CancellationToken cancellationToken = default)
 100        {
 0101            if (location == null)
 102            {
 0103                throw new ArgumentNullException(nameof(location));
 104            }
 105
 0106            using var message = CreateListRequest(location);
 0107            _pipeline.Send(message, cancellationToken);
 0108            switch (message.Response.Status)
 109            {
 110                case 200:
 111                    {
 0112                        AvailableDelegationsResult value = default;
 0113                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0114                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 115                        {
 0116                            value = null;
 117                        }
 118                        else
 119                        {
 0120                            value = AvailableDelegationsResult.DeserializeAvailableDelegationsResult(document.RootElemen
 121                        }
 0122                        return Response.FromValue(value, message.Response);
 123                    }
 124                default:
 0125                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 126            }
 0127        }
 128
 129        internal HttpMessage CreateListNextPageRequest(string nextLink, string location)
 130        {
 0131            var message = _pipeline.CreateMessage();
 0132            var request = message.Request;
 0133            request.Method = RequestMethod.Get;
 0134            var uri = new RawRequestUriBuilder();
 0135            uri.Reset(endpoint);
 0136            uri.AppendRawNextLink(nextLink, false);
 0137            request.Uri = uri;
 0138            return message;
 139        }
 140
 141        /// <summary> Gets all of the available subnet delegations for this subscription in this region. </summary>
 142        /// <param name="nextLink"> The URL to the next page of results. </param>
 143        /// <param name="location"> The location of the subnet. </param>
 144        /// <param name="cancellationToken"> The cancellation token to use. </param>
 145        public async Task<Response<AvailableDelegationsResult>> ListNextPageAsync(string nextLink, string location, Canc
 146        {
 0147            if (nextLink == null)
 148            {
 0149                throw new ArgumentNullException(nameof(nextLink));
 150            }
 0151            if (location == null)
 152            {
 0153                throw new ArgumentNullException(nameof(location));
 154            }
 155
 0156            using var message = CreateListNextPageRequest(nextLink, location);
 0157            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0158            switch (message.Response.Status)
 159            {
 160                case 200:
 161                    {
 0162                        AvailableDelegationsResult value = default;
 0163                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0164                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 165                        {
 0166                            value = null;
 167                        }
 168                        else
 169                        {
 0170                            value = AvailableDelegationsResult.DeserializeAvailableDelegationsResult(document.RootElemen
 171                        }
 0172                        return Response.FromValue(value, message.Response);
 173                    }
 174                default:
 0175                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 176            }
 0177        }
 178
 179        /// <summary> Gets all of the available subnet delegations for this subscription in this region. </summary>
 180        /// <param name="nextLink"> The URL to the next page of results. </param>
 181        /// <param name="location"> The location of the subnet. </param>
 182        /// <param name="cancellationToken"> The cancellation token to use. </param>
 183        public Response<AvailableDelegationsResult> ListNextPage(string nextLink, string location, CancellationToken can
 184        {
 0185            if (nextLink == null)
 186            {
 0187                throw new ArgumentNullException(nameof(nextLink));
 188            }
 0189            if (location == null)
 190            {
 0191                throw new ArgumentNullException(nameof(location));
 192            }
 193
 0194            using var message = CreateListNextPageRequest(nextLink, location);
 0195            _pipeline.Send(message, cancellationToken);
 0196            switch (message.Response.Status)
 197            {
 198                case 200:
 199                    {
 0200                        AvailableDelegationsResult value = default;
 0201                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0202                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 203                        {
 0204                            value = null;
 205                        }
 206                        else
 207                        {
 0208                            value = AvailableDelegationsResult.DeserializeAvailableDelegationsResult(document.RootElemen
 209                        }
 0210                        return Response.FromValue(value, message.Response);
 211                    }
 212                default:
 0213                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 214            }
 0215        }
 216    }
 217}