< Summary

Class:Azure.ResourceManager.EventHubs.RegionsRestOperations
Assembly:Azure.ResourceManager.EventHubs
File(s):C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.ResourceManager.EventHubs\src\Generated\RegionsRestOperations.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%
CreateListBySkuRequest(...)-0%100%
ListBySkuAsync()-0%0%
ListBySku(...)-0%0%
CreateListBySkuNextPageRequest(...)-0%100%
ListBySkuNextPageAsync()-0%0%
ListBySkuNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.ResourceManager.EventHubs\src\Generated\RegionsRestOperations.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.EventHubs.Models;
 16
 17namespace Azure.ResourceManager.EventHubs
 18{
 19    internal partial class RegionsRestOperations
 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 RegionsRestOperations. </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"> Subscription credentials that uniquely identify a Microsoft Azure subscription
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 032        public RegionsRestOperations(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 CreateListBySkuRequest(string sku)
 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.EventHub/sku/", false);
 056            uri.AppendPath(sku, true);
 057            uri.AppendPath("/regions", false);
 058            uri.AppendQuery("api-version", "2017-04-01", true);
 059            request.Uri = uri;
 060            return message;
 61        }
 62
 63        /// <summary> Gets the available Regions for a given sku. </summary>
 64        /// <param name="sku"> The sku type. </param>
 65        /// <param name="cancellationToken"> The cancellation token to use. </param>
 66        public async Task<Response<MessagingRegionsListResult>> ListBySkuAsync(string sku, CancellationToken cancellatio
 67        {
 068            if (sku == null)
 69            {
 070                throw new ArgumentNullException(nameof(sku));
 71            }
 72
 073            using var message = CreateListBySkuRequest(sku);
 074            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 075            switch (message.Response.Status)
 76            {
 77                case 200:
 78                    {
 079                        MessagingRegionsListResult 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 = MessagingRegionsListResult.DeserializeMessagingRegionsListResult(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 the available Regions for a given sku. </summary>
 97        /// <param name="sku"> The sku type. </param>
 98        /// <param name="cancellationToken"> The cancellation token to use. </param>
 99        public Response<MessagingRegionsListResult> ListBySku(string sku, CancellationToken cancellationToken = default)
 100        {
 0101            if (sku == null)
 102            {
 0103                throw new ArgumentNullException(nameof(sku));
 104            }
 105
 0106            using var message = CreateListBySkuRequest(sku);
 0107            _pipeline.Send(message, cancellationToken);
 0108            switch (message.Response.Status)
 109            {
 110                case 200:
 111                    {
 0112                        MessagingRegionsListResult 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 = MessagingRegionsListResult.DeserializeMessagingRegionsListResult(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 CreateListBySkuNextPageRequest(string nextLink, string sku)
 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 the available Regions for a given sku. </summary>
 142        /// <param name="nextLink"> The URL to the next page of results. </param>
 143        /// <param name="sku"> The sku type. </param>
 144        /// <param name="cancellationToken"> The cancellation token to use. </param>
 145        public async Task<Response<MessagingRegionsListResult>> ListBySkuNextPageAsync(string nextLink, string sku, Canc
 146        {
 0147            if (nextLink == null)
 148            {
 0149                throw new ArgumentNullException(nameof(nextLink));
 150            }
 0151            if (sku == null)
 152            {
 0153                throw new ArgumentNullException(nameof(sku));
 154            }
 155
 0156            using var message = CreateListBySkuNextPageRequest(nextLink, sku);
 0157            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0158            switch (message.Response.Status)
 159            {
 160                case 200:
 161                    {
 0162                        MessagingRegionsListResult 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 = MessagingRegionsListResult.DeserializeMessagingRegionsListResult(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 the available Regions for a given sku. </summary>
 180        /// <param name="nextLink"> The URL to the next page of results. </param>
 181        /// <param name="sku"> The sku type. </param>
 182        /// <param name="cancellationToken"> The cancellation token to use. </param>
 183        public Response<MessagingRegionsListResult> ListBySkuNextPage(string nextLink, string sku, CancellationToken can
 184        {
 0185            if (nextLink == null)
 186            {
 0187                throw new ArgumentNullException(nameof(nextLink));
 188            }
 0189            if (sku == null)
 190            {
 0191                throw new ArgumentNullException(nameof(sku));
 192            }
 193
 0194            using var message = CreateListBySkuNextPageRequest(nextLink, sku);
 0195            _pipeline.Send(message, cancellationToken);
 0196            switch (message.Response.Status)
 197            {
 198                case 200:
 199                    {
 0200                        MessagingRegionsListResult 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 = MessagingRegionsListResult.DeserializeMessagingRegionsListResult(document.RootElemen
 209                        }
 0210                        return Response.FromValue(value, message.Response);
 211                    }
 212                default:
 0213                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 214            }
 0215        }
 216    }
 217}